How to end a thread in java?
Posted
by beagleguy
on Stack Overflow
See other posts from Stack Overflow
or by beagleguy
Published on 2010-05-31T20:50:18Z
Indexed on
2010/05/31
21:03 UTC
Read the original article
Hit count: 232
java
hi all, I have 2 pools of threads
ioThreads = (ThreadPoolExecutor)Executors.newCachedThreadPool();
cpuThreads = (ThreadPoolExecutor)Executors.newFixedThreadPool(numCpus);
I have a simple web crawler that I want to create an iothread, pass it a url, it will then fetch the url and pass the contents over to a cpuThread to be processed and the ioThread will then fetch another url, etc...
At some point the IO thread will not have any new pages to crawl and I want to update my database that this session is complete. How can I best tell when the threads are all done processing and the program can be ended?
© Stack Overflow or respective owner