Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Better than ThreadPoolExecutor  RSS feed

 
Sandip Bose
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any better way to execute concurrent threads other than ThreadPoolExecutor?

 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sandip,

I think there's not only ONE way to execute threads concurrently. It depends on your requirements as so often ;-)

Or do you think ThreadPoolExecutor is not good enough for the job you want to do?

Marco
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what you are trying to accomplish, but if you want to schedule threads in a way similar to cron then the quartz scheduler is powerful.
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's right. I recently used Quartz on a project and was very happy with it because it's very powerful and at the same easy to use.

But as Steve pointed out it's not easy to help you without knowing more about reason for your question!
 
Sandip Bose
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all of you for your support.

Actually i wanted to know how to run maximum number of threads concurrently???

Is it possible to run 100 threads concurrently in Quartz?
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure. But, it should be easy enough to add that capability to any class. Just have a method that increments a counter each time a thread is started and check this value before you start a thread. It should be synchronized.
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

in my experience Quartz should be used as a scheduler which is its primary goal, i.e. if you have to control the time/date of execution for specific tasks.

If you simply want to execute 100 worker threads in parallel for doing some kind of jobs a ThreadPoolExecutor is most probably a perfect solution for this kind of requirement as you don't have to worry about thread creation and management and instead only define what jobs should be executed.

marco
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does not really have anything specific to performance, moving to Threads forum
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!