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 Thread Pool in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread Pool in Java" Watch "Thread Pool in Java" New topic

Thread Pool in Java

Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328

I want to write Thread Poolusing Java for some repititve task which is controlled through Job Scheduler.Job Scheduler will run after interval of 2 minutes.Can you please provide me few guidelines regarding how to write thread pool in Java.

My application will be deployed on Application Server and I am using JDK 1.4. I know there is a java.util.concurrent.Executors class which can be used for this. However, It's available in JDK 1.5 & not in 1.4

Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
You can use the java.util.concurrent backport to get most of the concurrent functionality in earlier JDK versions. There are also other thread pool implementations out there, or you could write your own, but unless you're doing this as a learning exercise, using java.util.concurrent is probably easiest.
[ May 01, 2008: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
Mintoo kumar
Ranch Hand

Joined: Aug 21, 2007
Posts: 61
Creating a ThreadPool logically vary from people to people.The easiest of creating a thread pool is to use java data structure (Hashtable,Hashmap prefferably) and take boolean variable ,just to identify(whether this thread in use or not).This is somewhat similar to connection pool maintain by the webserver/Application server.

Hope above hint will be helpful for you in someway.

SCJP 1.4
I agree. Here's the link:
subject: Thread Pool in Java
It's not a secret anymore!