Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

advice on managing a thread pool

Status
Not open for further replies.

wduty

Programmer
Jun 24, 2000
271
US
I have a thread pool that I use to run a bunch of URLConnections simultaneously. The pool is structured like this:

1. A class called ThreadPool starts 10 instances of a thread class called WorkerThread.

2. Each WorkerThread accesses the same static instance of a third class called TaskQueue which puts tasks into a vector in a sychronized method. The WorkerThreads pull tasks out of the vector (if any are available).

3. A result of the tasks is that more tasks are put in the queue (for a while, depending on the situation).

I've been having problems with this program because, although it runs as intended, after running it many times the DOS prompt tends to lock up and occasionally my computer crashes. Perhaps a lot of stray threads are left running? What would be the best way to ensure that the threads in this pool are stopped and garbage collected when the frame is closed?

I read through the tutorials at sun but they seemed to apply to a different situation. Thread.stop() is deprecated but would it apply in this situation? I've seen people set thread instances to null on system.exit(). Is that any good?

Any other advice on thread pooling appreciated.

--Will Duty
wduty@radicalfringe.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top