摘要:
1. 阅读全文
posted @ 2017-12-01 22:37
黑土白云
阅读(201)
评论(0)
推荐(0)
摘要:
1. final List<String> synchronizedList = Collections.synchronizedList(tickets);//list变成线程安全的 1 public class Tickets { 2 public static void main(String 阅读全文
posted @ 2017-12-01 22:10
黑土白云
阅读(280)
评论(0)
推荐(0)
该文被密码保护。 阅读全文
posted @ 2017-12-01 22:04
黑土白云
阅读(2)
评论(0)
推荐(0)
摘要:
1. 1 public class ListAdd2 { 2 private volatile static List list = new ArrayList(); 3 4 public void add(){ 5 list.add("hello"); 6 } 7 8 public int siz 阅读全文
posted @ 2017-12-01 22:00
黑土白云
阅读(422)
评论(0)
推荐(0)
摘要:
1. 1 public class ListAdd1 { 2 private volatile static List list = new ArrayList(); 3 4 public void add(){ 5 list.add("hello"); 6 } 7 8 public int siz 阅读全文
posted @ 2017-12-01 21:55
黑土白云
阅读(149)
评论(0)
推荐(0)
摘要:
1. 1 public class VolatileNoAtomic extends Thread { 2 private static volatile int count; //volatile具有线程间的变量的可见性不具备原子性 3 4 public void run(){ 5 addCoun 阅读全文
posted @ 2017-12-01 21:43
黑土白云
阅读(215)
评论(0)
推荐(0)
摘要:
1. 改成static也不行 private static boolean isRunning = true; volatile关键字主要用于线程变量在多个线程之间的可见 1 public class RunThread extends Thread{ 2 private volatile bool 阅读全文
posted @ 2017-12-01 21:22
黑土白云
阅读(274)
评论(0)
推荐(0)
摘要:
1. 1 public class SyncDubbo2 { 2 static class Sup{ //父类 3 public int i = 10; 4 public synchronized void operSup(){ 5 try{ 6 i--; 7 System.out.println( 阅读全文
posted @ 2017-12-01 20:19
黑土白云
阅读(110)
评论(0)
推荐(0)
摘要:
1. 1 public class SyncDubbo1 { 2 public synchronized void method1(){ 3 System.out.println("method1..."); 4 method2(); 5 } 6 public synchronized void m 阅读全文
posted @ 2017-12-01 20:11
黑土白云
阅读(123)
评论(0)
推荐(0)
摘要:
1. 1 public class DirtyRead { 2 private String username = "ck"; 3 private String password = "123"; 4 5 public synchronized void setValue(String userna 阅读全文
posted @ 2017-12-01 20:09
黑土白云
阅读(192)
评论(0)
推荐(0)
该文被密码保护。 阅读全文
posted @ 2017-12-01 19:53
黑土白云
阅读(1)
评论(0)
推荐(0)
摘要:
1. 1 public class MultiThread { 2 private static int num = 0; 3 4 public static synchronized void printNum(String tag){ 5 if("a".equals(tag)){ 6 Syste 阅读全文
posted @ 2017-12-01 19:50
黑土白云
阅读(153)
评论(0)
推荐(1)
摘要:
1. 1 public class MyThread extends Thread{ 2 private int count = 5; 3 4 @Override 5 public synchronized void run() { 6 count--; 7 System.out.println(T 阅读全文
posted @ 2017-12-01 19:45
黑土白云
阅读(167)
评论(0)
推荐(0)
浙公网安备 33010602011771号