java 线程数据同步 由买票实例 //java线程实例 //线程数据同步 //卖票问题 //避免重复卖票 //线程 class xc1 implements Runnable{ //定义为静态,可以使多个对象使用同一个数据 public static int chepiao = 10; //车票总数 public static String aa = new String("123"); //字符串随意定义,定义在函数上面 public void run(){ while(true)
/** * Return whether the given throwable is a checked exception: * that is, neither a RuntimeException nor an Error. * @param ex the throwable to check * @return whether the throwable is a checked exception * @see java.lang.Exception * @see java.lang