“Cannot reproduce” - is Java deterministic multithreading possible?

前端 未结 3 1999
隐瞒了意图╮
隐瞒了意图╮ 2021-01-18 03:45

Is this possible to run multithreaded Java application in a deterministic fashion? I mean to have always the same thread switching in two different runs of my application.

3条回答
  •  星月不相逢
    2021-01-18 04:19

    No it is not possible (other than to simulate it yourself) to use multiple threads interleaving in the same way each time around. Threads are not designed to do that.

    If you want deterministic results, don't use threads.

提交回复
热议问题