内容发布更新时间 : 2025/1/23 15:02:05星期一 下面是文章的全部内容请认真阅读。
class A implements Runnable { Thread zhangXiao,zhengMing,teacher;
A( { teacher=new Thread(this; zhangXiao=new Thread(this; zhangXiao.setName(\张小\zhengMing=new Thread(this; zhengMing.setName(\郑明\
run( { if(Thread.currentThread(==zhangXiao { try{ System.out.printf(\休息10秒后再说问候语\\n\catch(InterruptedException e { System.out.printf(\被吵醒了\早上好!\
if(Thread.currentThread(==zhengMing { try{ System.out.printf(\休息10秒后再说问候语\\n\{ System.out.printf(\被吵醒了\morning!\
{ System.out.printf(\上课!\zhengMing.interrupt(; //吵醒zhengMing。 zhangXiao.interrupt(; //吵醒
zhangXiao。 } } } class Example { public static void main(String args[] { A a=new A(; a.zhangXiao.start(; a.zhengMing.start(; a.teacher.start(; } }