File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Threads and Synchronization and the fly likes ThreadPool with different tasks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "ThreadPool with different tasks" Watch "ThreadPool with different tasks" New topic

ThreadPool with different tasks

Doua Beri
Ranch Hand

Joined: Sep 24, 2009
Posts: 60
Hello everyone. I have an information question. In my application the user sets the number of threads that should run a certain type of code( task).

in my source code there are 2 different type of tasks that needs to be run by the ThreadPool. information saved in a database by the first task is needed in the second task. Task are being added(scheduled) to the threadpool by a timer task that runs every 10 seconds.

So... my question is how is better to use:
a) One ThreadPool that runs those 2 different tasks. I already use this option but I have problems in balancing the scheduled number of tasks that will run in some future.
b) two threadpool one for every task -seems an easy option for me, but not such cleaner as the first( in my opinion)

If you think the solution from point a) is much better can you help me with some general information about how to build an balanced scheduled task system so on the threadpool should not run only the first or the second task.

Thanks in advanced
I agree. Here's the link:
subject: ThreadPool with different tasks