Weird problem using JUnit in multi-thread environment

前端 未结 5 1043
耶瑟儿~
耶瑟儿~ 2020-12-16 05:03

I meet a weired problem when using JUnit in multi-thread environment. The following code should fail, but it actually pass in eclipse.

public class ExampleT         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-16 05:41

    There is also the interesting fact that Eclipse and IDEA can spawn a VM in their junit test runners and end up calling system.exit() on it. This means if you don't wait properly in the test (as in the case when you sleep above and hope the the task has completed), it can exit unexpectedly. Interesting, but not exactly what you were asking!

    see this link for details...

提交回复
热议问题