Java基础进阶案例教程(课件)例7-3.docxVIP

  • 12
  • 0
  • 约小于1千字
  • 约 3页
  • 2018-12-28 发布于江西
  • 举报
class NumberChange{ private int x=0; private int y=0; void increase(){ x++; y++; } void testEqual(){ System.out.println(x+,+y+:+(x==y)); } } class Counter extends Thread{ private NumberChange num; Counter(NumberChange num){ this.num=num; } public void run(){ while(true){ num.increase(); } } } public class Example7_3{ public static void main(String[] args){ NumberChange num = new NumberChange(); Thread count1 = new Counter(num); Thread count2 = new Counter(num); count1.start(); count2.start(); for(int i=0;i50;i++){ num.testEqual(); try{ Thread.s

文档评论(0)

1亿VIP精品文档

相关文档