甚至在线程睡眠异常抛出后出错

问题描述 投票:0回答:2

[我正在尝试使我的线程休眠,并使该方法抛出InterruptedException,但是它仍然给出错误“未处理的异常”


  @Before
    public void setUp() throws InterruptedException{

        simulatorList.forEach(simulation -> {
           ....
            Thread.sleep(1000*60*1);
//giving error here 

            ...
        });
}
java
2个回答
0
投票

因为您在foreach中调用Thread.sleep,下面将解决您的问题:
© www.soinside.com 2019 - 2024. All rights reserved.