开发者

can i join the threads that a ThreadPoolExecutor creates

I'm using ThreadPoolExecutor to make it easy to create threads to handle requests but now a requirement is to execute the requests in order. I was wondering if i can use the join method to make a thread get executed right after a previous launched thread finishes.

i've been look开发者_如何学运维ing at the api but i haven't found a method that returns the Thread object from the ThreadPoolExecutor

Can i do that? or do i need to implement something like my own thread factory to do this?


If you don't want the requests to happen concurrently, you can use java.util.concurrent.Executors.newSingleThreadExecutor() and they'll happen one at a time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜