synchronized thread execution

后端 未结 4 975
终归单人心
终归单人心 2021-01-22 17:27

my task is to create thread in this order: if A start->start B and C, if B start->start D. And destroy them in reverse order If D then B. If B and C then A. I hope you get it.

4条回答
  •  感动是毒
    2021-01-22 17:55

    In multi threading, there is no need of synchronization unless the common data is shared by multiple threads. In your case, you want to start and stop the threads in a particular order. For this, there is join method in Thread class. This link shows good example of join method.

提交回复
热议问题