I just want to insert a batch of tasks into it, and do not want to lost any one.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
@virsir,
You’d asked specifically about creating an instance
ThreadPoolExecutor. But I’m wondering whether it would be okay to have any class that implements theExecutorServiceinterface. SinceThreadPoolExecutorimplementsExecutorService, this isn’t much of a leap.The
java.util.concurrent.Executorsclass provides some useful functions for creating thread pools that handle some common situations.I’ve recently used
Executors.newFixedThreadPool()in a project to create several different thread pools. It returns an object that implements ExecutorService. I had no trouble submitting tens of thousands of Runnable instances to a pool of 10 threads, and it worked quite smoothly.Per the Java 5 docs, this method:
Since the method is said to create an “unbounded queue”, there should be no artificial limits on the number of tasks one can submit.