随笔分类 -  4.多线程高并发

摘要:1.无volatile /**volatile 有序性验证 * @author xueci * */ public class TestSequence { static int a,b; static int x,y; public static void main(String[] args) 阅读全文
posted @ 2020-04-22 15:23 雪辞妹 阅读(874) 评论(1) 推荐(0)
摘要:/**无法保证原子性 * @author 雪辞 * */public class TestAtomicity {private volatile static int count=0;public static void main(String[] args) { //启动十个线程 for (int 阅读全文
posted @ 2020-04-22 14:34 雪辞妹 阅读(139) 评论(0) 推荐(0)
摘要:代码1:不使用volatile /**volatile 可见性* @author 雪辞**/public class TestVisibility { private boolean initFlag=false;public void refresh(){ this.initFlag=true; 阅读全文
posted @ 2020-04-22 13:41 雪辞妹 阅读(139) 评论(0) 推荐(0)