|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
认真的记,感觉很紧张根本就没有时间和能力,来对技术知识点进行思考。这样课下就只能对知识进行简单的理解,其实简单的理解就是记忆课堂上讲的知识点,
publicclassroad
{
publicstaticvoidmain(String[]args)
{
carc=newcar();
driverd=newdriver(c);
passengerp=newpassenger(c);
newThread(d).start();
newThread(p).start();
}
}
classcar
{
synchronizedpublicvoidsleep()
{
try{
wait();
}
catch(Exceptione)
{
}
}
synchronizedpublicvoidweek()
{
notify();
}
}
classpassengerimplementsRunnable
{
carc;
publicpassenger()
{
}
publicpassenger(carc)
{
this.c=c;
}
publicvoidrun()
{
while(true)
{
Thread.yield();
try{
Thread.sleep(3000);
}catch(InterruptedExceptionie)
{
}
System.out.println("apassengergoon");
c.week();
System.out.println("waitingstopandsleep...");
c.sleep();
}
}
}
classdriverimplementsRunnable
{
privatecarc;
publicdriver()
{
}
publicdriver(carc)
{
this.c=c;
}
publicvoidrun()
{
while(true)
{
System.out.println("waitapassenger.......");
c.sleep();
try{
Thread.sleep(3000);
}catch(InterruptedExceptionie)
{
}
Thread.yield();
try{
Thread.sleep(100);
}catch(InterruptedExceptionie)
{
}
c.week();
System.out.println("passengerweekandgo");
}
}}
C#是盗用了Java的源代码,仿照开发的,原因是Java是开源的啊,盗了也白盗,还有一点,开发C#语言的团队是就是开发Java语言的团队,是微软重金挖过去的啊 |
|