开发者

can i join the threads that a ThreadPoolExecutor creates

开发者 https://www.devze.com 2023-04-02 07:33 出处:网络
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 thr

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

精彩评论

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

关注公众号