“无法重现”——Java 确定性多线程可能吗?

2023-11-24

是否可以以确定性方式运行多线程 Java 应用程序?我的意思是在我的应用程序的两次不同运行中始终具有相同的线程切换。

原因是每次运行时都在完全相同的条件下运行模拟。

类似的情况是,当使用随机数生成器时给出一些任意种子以获得始终相同的“随机”序列。


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

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.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

“无法重现”——Java 确定性多线程可能吗? 的相关文章

随机推荐