摘要: 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)
摘要: /** * 约瑟夫杀人 * n个人首位相连,依次从1数到5,数到5(m)就杀一个人,最后剩下谁 * @author xueci * */public class TestJosephus { int n=20; int m=5; class People{ int index; People nex 阅读全文
posted @ 2020-04-11 12:52 雪辞妹 阅读(352) 评论(0) 推荐(0)
摘要: public class TestEightQueen { public static void main(String[] args) { TestEightQueen queen = new TestEightQueen(); queen.getCount(0); } int num = 0; 阅读全文
posted @ 2020-04-09 22:36 雪辞妹 阅读(242) 评论(0) 推荐(0)
摘要: SETBIT key offset value对 key 所储存的字符串值,设置或清除指定偏移量上的位(bit)。 在redis中,存储的字符串都是以二级制的进行存在的。 举例:设置一个 key-value ,键的名字叫“andy” 值为字符'a' 我们知道 'a' 的ASCII码是 97。转换为二 阅读全文
posted @ 2019-02-20 11:21 雪辞妹 阅读(1299) 评论(0) 推荐(0)