[英]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. 我正在使用ThreadPoolExecutor轻松创建线程来处理请求,但是现在的要求是按顺序执行请求。 I was wondering if i can use the join method to make a thread get executed right after a previous launched thread finishes.
我想知道我是否可以使用join方法使一个线程在先前启动的线程完成后立即执行。
i've been looking at the api but i haven't found a method that returns the Thread object from the ThreadPoolExecutor 我一直在看api,但是我没有找到从ThreadPoolExecutor返回Thread对象的方法
Can i do that? 我可以那样做吗? or do i need to implement something like my own thread factory to do this?
还是我需要实现像我自己的线程工厂这样的东西?
如果您不希望请求同时发生,则可以使用java.util.concurrent.Executors.newSingleThreadExecutor()
,它们将一次出现一次。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.