• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using an executor  RSS feed

 
Deyna Cegielski
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've created my own PooledExecutor to create and manage a variable size thread pool. I've become a bit unstuck as to how to actually "initiate" the executor so to speak so that it begins to create threads and assign tasks to them.

Thanks
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Deyna Cegielski:
I've created my own PooledExecutor to create and manage a variable size thread pool. I've become a bit unstuck as to how to actually "initiate" the executor so to speak so that it begins to create threads and assign tasks to them.

Thanks


Hi Deyna,
If you are using java 5 then different types of executors are available. You do not need to write one.
If not, then sharing the code, will probably help in understanding where you are stuck.
 
Deyna Cegielski
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, in that light, lets forget about how ive implemented the executor, using one of the executors in Java 5, how would i initialise it to start managing the threads and tasks?
 
Henry Wong
author
Sheriff
Posts: 22865
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Deyna Cegielski:
Thanks, in that light, lets forget about how ive implemented the executor, using one of the executors in Java 5, how would i initialise it to start managing the threads and tasks?


The easiest place to start is with the convenience factory for executors. One of the factory methods should provide you with a executor that would work. If that is not the case, you can click on the Javadoc from that page, to configure an executor to your specifications.

Henry
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Creating an instance of the executor initialize it and submitting a task via execute method executes the task.
Pls. refer to api for api details.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a real life example to show how darned simple it is to use such complex goodies. This is a web server ...

This particular executor creates new threads without bounds and terminates them if they're idle for a minute.
 
Deyna Cegielski
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, that was what i was after, a pool of x threads continuously running and services requests until the requests stop!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!