java并发之固定对象与实例 Immutable Objects An object is considered immutable if its state cannot change after it is constructed. Maximum reliance on immutable objects is widely accepted as a sound strategy for creating simple, reliable code. Immutable objects…
java 线程数据同步 由买票实例 //java线程实例 //线程数据同步 //卖票问题 //避免重复卖票 //线程 class xc1 implements Runnable{ //定义为静态,可以使多个对象使用同一个数据 public static int chepiao = 10; //车票总数 public static String aa = new String("123"); //字符串随意定义,定义在函数上面 public void run(){ while(true)…