エラーは後でさえものThread.sleepの例外がスローされます

デニス:

私は、しかし、それはまだエラー「未処理の例外」を与えている、私のスレッドの睡眠を作るしようとしていますし、この方法は、例外:InterruptedExceptionをスロー作っています


  @Before
    public void setUp() throws InterruptedException{

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

            ...
        });
}
アフマドマダウィ:

あなたはforeachの内部でのThread.sleepを呼び出すので、以下は、あなたの問題を解決します。

public void setUp() throws InterruptedException {
    List<String> simulatorList = new ArrayList<>();
    for (String s : simulatorList) {
        Thread.sleep(1000 * 60 * 1);
    }
}

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=23518&siteId=1