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

Using ExecutorService instead of regular Threads  RSS feed

 
Michael Duff
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I have 3 classes, each one which implements Runnable. What would be the ideal way of using Executor/ExecutorService so I don't need to use Thread.start() method in each one of them?

Here I have one of the classes
 
K Abhijit
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This would address your requirements but not sure how effectively....

Define the thread Pool:

KickStarts the thread:

rest is same
 
Michael Duff
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the tip, but I'm looking for something more simple where I could use Future, something like this:




But I'm clueless how to properly implement that functionality into my class in the first post (and my two other classes). Do I need to send the objects to the threadpool in the constructors of my classes?
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Threads and Synchronization.
 
Michael Duff
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any ideas/suggestions would be appreciated
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!