“Cannot reproduce” - is Java deterministic multithreading possible?

前端 未结 3 2031
隐瞒了意图╮
隐瞒了意图╮ 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:37

    I am not aware of any practical way to do this.

    In theory, it would be possible to implement a bytecode interpreter with an entirely deterministic behavior under certain assumptions1. You would need to simulate the multiple threads by implementing the threads and the thread scheduling entirely in software and using a single native thread.


    1 - For example, no I/O, and no use of the system clock.

提交回复
热议问题