best approach?...creating new Thread or using Thread pool

Hi,

Assume you will receive 100 request/min to process and each request will take 2 mins. the request will keep on coming.

for this assumption, Please can anyone tell me which approach is best? Creating a new Thread for each request or using Thread pool. can you justify with analytical data(like time taken to execute).

and also please tell me when not to use Thread pool.

Thanks...

Babu Shanmugham

[436 byte] By [babusha] at [2007-11-27 11:10:03]
# 1

You can create new thread for every request and execute. For more detials for this plz see below link

http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html

rajanalaja at 2007-7-29 13:39:15 > top of Java-index,Java Essentials,Java Programming...
# 2

Obivously you will need a ThreadPool of at least 200 threads to keep up with the arriving requests.

By elementary queueing theory you should keep usage down to no more than 70% on average, so you will need 285 threads in reality if you used a thread pool.

100 requests per minute isn't a high arrival rate, and the overhead of Thread creation at this low rate probably doesn't really justify a thread pool, but you would have to test and measure for yourself on your target hardware.

ejpa at 2007-7-29 13:39:15 > top of Java-index,Java Essentials,Java Programming...