摘要:
1. 阅读全文
摘要:
1. final List<String> synchronizedList = Collections.synchronizedList(tickets);//list变成线程安全的 1 public class Tickets { 2 public static void main(String 阅读全文
该文被密码保护。 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
1. 1 public class VolatileNoAtomic extends Thread { 2 private static volatile int count; //volatile具有线程间的变量的可见性不具备原子性 3 4 public void run(){ 5 addCoun 阅读全文
摘要:
1. 改成static也不行 private static boolean isRunning = true; volatile关键字主要用于线程变量在多个线程之间的可见 1 public class RunThread extends Thread{ 2 private volatile bool 阅读全文
摘要:
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( 阅读全文
摘要:
1. 1 public class SyncDubbo1 { 2 public synchronized void method1(){ 3 System.out.println("method1..."); 4 method2(); 5 } 6 public synchronized void m 阅读全文
摘要:
1. 1 public class DirtyRead { 2 private String username = "ck"; 3 private String password = "123"; 4 5 public synchronized void setValue(String userna 阅读全文
该文被密码保护。 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文