This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
wood burning stoves
subject: ThreadPool with different tasks
Similar Threads
Timer Service Accuracy
Need Help with Timer Class
Simple Thread Question
Threads and DB Access
questions java.util.Timer