摘要:
classJoinThreadDemo{publicstaticvoidmain(String[]args){JoinThreadjoinThread=newJoinThread();Threadt1=newThread(joinThread,"t1");Threadt2=newThread(joinThread,"t2");t1.start();try{t1.join();}catch(Exceptione){System.out.println(Thread.currentThread().getName()+"Exception" 阅读全文
posted @ 2013-01-15 14:10
陈晓明
阅读(465)
评论(0)
推荐(0)
摘要:
classThreadDemo{publicstaticvoidmain(String[]args){newThread(){publicvoidrun(){for(inti=0;i<100;i++){System.out.println(Thread.currentThread().getName()+"...."+i);}}}.start();for(inti=0;i<100;i++){System.out.println(Thread.currentThread().getName()+"...."+i);}Runnabler=newR 阅读全文
posted @ 2013-01-15 14:10
陈晓明
阅读(469)
评论(0)
推荐(0)
摘要:
classDaemonThreadDemo{publicstaticvoidmain(String[]args){StopThreadstopThread=newStopThread();Threadt1=newThread(stopThread,"t1");Threadt2=newThread(stopThread,"t2");t1.setDaemon(true);t2.setDaemon(true);t1.start();t2.start();intnum=0;while(true){if(num++==60){stopThread.changeFl 阅读全文
posted @ 2013-01-15 13:16
陈晓明
阅读(587)
评论(0)
推荐(0)
摘要:
classStopThreadDemo{publicstaticvoidmain(String[]args){StopThreadstopThread=newStopThread();Threadt1=newThread(stopThread,"t1");Threadt2=newThread(stopThread,"t2");t1.start();t2.start();intnum=0;while(true){if(num++==60){//this.changeFlag();t1.interrupt();t2.interrupt();break;}Sy 阅读全文
posted @ 2013-01-15 13:10
陈晓明
阅读(180)
评论(0)
推荐(0)
摘要:
classProducerConsumerDemo{publicstaticvoidmain(String[]args){Productproduct=newProduct();newThread(newProducer(product)).start();newThread(newConsumer(product)).start();newThread(newProducer(product)).start();newThread(newConsumer(product)).start();newThread(newProducer(product)).start();newThread(n 阅读全文
posted @ 2013-01-15 12:15
陈晓明
阅读(293)
评论(0)
推荐(0)
摘要:
classProducerConsumerDemo{publicstaticvoidmain(String[]args){Productproduct=newProduct();newThread(newProducer(product)).start();newThread(newConsumer(product)).start();}}classProduct{privateintcount;privatebooleanflag;publicsynchronizedvoidcreate(){while(this.flag){try{this.wait();}catch(Exceptio.. 阅读全文
posted @ 2013-01-15 12:07
陈晓明
阅读(327)
评论(0)
推荐(0)
摘要:
classThreadCommunicationDemo{publicstaticvoidmain(String[]args){Resourceresource=newResource();Inputinput=newInput(resource);Outputoutput=newOutput(resource);newThread(input,"inputthread").start();newThread(output,"outputthread").start();}}classInputimplementsRunnable{privateReso 阅读全文
posted @ 2013-01-15 11:23
陈晓明
阅读(224)
评论(0)
推荐(0)
摘要:
classThreadCommunicationDemo{publicstaticvoidmain(String[]args){Resourceresource=newResource();Inputinput=newInput(resource);Outputoutput=newOutput(resource);newThread(input,"inputthread").start();newThread(output,"outputthread").start();}}classInputimplementsRunnable{privateReso 阅读全文
posted @ 2013-01-15 11:15
陈晓明
阅读(259)
评论(0)
推荐(0)

浙公网安备 33010602011771号