java 线程安全问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public class ThreadA  implements Runnable{
    public static int number;
    public String test;
    @Override
    public void run() {
 
        while(true){
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

  number是共享资源,属于非线程安全,test属于线程安全

posted @   Fly_Coding  阅读(116)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示