How to execute tasks in ExecutorService sequentially?

后端 未结 3 739
遇见更好的自我
遇见更好的自我 2020-12-10 14:38

I have three threads that are joined, i.e. the second thread executes after the first dies.

This is the code I have:

public class Main {
    public s         


        
3条回答
  •  我在风中等你
    2020-12-10 15:25

    If you already use a thread pool in your application, you can reuse it by means of zero-threaded proxy serial executor, without creating special single threaded thread pool. One implementation is described in the javadoc section of Executor interface, another, optimized implementation, at my Github repository CodeSamples.

提交回复
热议问题