[我正在尝试使我的线程休眠,并使该方法抛出InterruptedException,但是它仍然给出错误“未处理的异常”
@Before
public void setUp() throws InterruptedException{
simulatorList.forEach(simulation -> {
....
Thread.sleep(1000*60*1);
//giving error here
...
});
}
因为您在foreach中调用Thread.sleep,下面将解决您的问题: