is it possible to define execution order for a set of threads in java

后端 未结 6 1890
离开以前
离开以前 2021-01-26 00:10

My understanding is that threads in theory are executed in parallel. JVM decides; when a resource is available which thread to pick from the waiting thread queue (based on some

6条回答
  •  天涯浪人
    2021-01-26 00:34

    Since java 8 this has become very easy using CompletableFuture :

    CompletableFuture.runAsync(runnable3)
                .thenRunAsync(runnable1)
                .thenRunAsync(runnable2);
    

提交回复
热议问题