且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

“无法复制” - Java确定性多线程可能吗?

更新时间:2023-01-18 23:40:30

我不知道有任何实际的方法可以做到这一点。

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

从理论上讲,它可以实现在某些假设 1 下具有完全确定性行为的字节码解释器。您需要通过完全在软件中并使用单个本机线程实现线程和线程调度来模拟多个线程。

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 - 例如,没有I / O,也没有使用系统时钟。