摘要: View Code 1 package StopThreadDemo; 2 class StopThreadDemo 3 { 4 public static void main(String[] age) 5 { 6 StopThread st = new StopThread(); 7 Thread t1=new Thread(st); 8 Thread t2=new Thread(st); 9 t1.start();10 t2.start();11 int num=0;12 ... 阅读全文
posted @ 2013-03-29 12:08 熊猫的战斗 阅读(134) 评论(0) 推荐(0)
摘要: View Code 1 package StopThreadDemo; 2 class StopThreadDemo 3 { 4 public static void main(String[] age)throws Exception 5 { 6 StopThread st = new StopThread(); 7 Thread t1=new Thread(st); 8 Thread t2=new Thread(st); 9 t1.setDaemon(true);10 11 ... 阅读全文
posted @ 2013-03-29 00:26 熊猫的战斗 阅读(215) 评论(0) 推荐(0)
摘要: View Code 1 /* 2 新版本锁的替换 lock! 3 4 */package shengchanxiaofei; 5 import java.util.concurrent.locks.*; 6 7 class shengchanxiaofei 8 { 9 public static void main(String[] age )10 {11 gongchang a=new gongchang();12 13 Thread t1=new Thread(new input(a));14 T... 阅读全文
posted @ 2013-03-28 11:35 熊猫的战斗 阅读(146) 评论(0) 推荐(0)
摘要: View Code /*主要用于wait()方法 和notify();的使用!程序主要是通过线程进行对象resume的输入输出操作*/package tongxinxiancheng;class resume{ String name; String xingbie; boolean flag=false;}class InPut implements Runnable{ private resume test; InPut(resume test) { this.test=test; } public void run() ... 阅读全文
posted @ 2013-03-28 01:39 熊猫的战斗 阅读(123) 评论(1) 推荐(1)
摘要: View Code 1 /* 2 主要用于wait()方法 和notify();的使用! 3 程序主要是通过线程进行对象resume的输入输出操作 4 5 */ 6 package tongxinxiancheng; 7 8 9 class resume10 {11 String name;12 String xingbie;13 boolean flag=false;14 }15 class InPut implements Runnable16 {17 private resume test;18 InPut(resume test)19 ... 阅读全文
posted @ 2013-03-28 01:33 熊猫的战斗 阅读(128) 评论(1) 推荐(0)
摘要: View Code 1 //死锁程序 2 class test implements Runnable 3 { 4 private boolean flag;//用来选择else程序 5 test(boolean flag) 6 { 7 this.flag=flag; 8 } 9 10 public void run()11 {12 if(flag) //与else交互调动产生死锁13 while(true)14 {15 ... 阅读全文
posted @ 2013-03-26 12:56 熊猫的战斗 阅读(118) 评论(1) 推荐(1)