Why does Java not see the updated value from another thread?

后端 未结 5 1136
隐瞒了意图╮
隐瞒了意图╮ 2020-11-28 14:35

Please look at this code(taken from Effective Java book)

import java.util.concurrent.TimeUnit;


public class Main {
private static boolean stopReq;
public s         


        
5条回答
  •  鱼传尺愫
    2020-11-28 15:06

    Make stopReq to true, then it will be stopped. You are again setting the stopReq to false, due to that while loop condition is true always and it is in infinite loop.

提交回复
热议问题