上一页 1 ··· 5 6 7 8 9 10 11 12 13 下一页
摘要: 1 class MyThreadA implements Runnable{ 2 private boolean flag=true; 3 public void run(){ 4 int i=0; 5 while(this.flag){ 6 while(true){ 7 System.out.println(Thread.currentThread().getName()+"运行,i="+(i++)); 8 } 9 }10 }11 }12 ... 阅读全文
posted @ 2012-03-13 21:05 谈笑风生膜法师 阅读(291) 评论(0) 推荐(0)
摘要: 1 class MyThread implements Runnable{ 2 private boolean flag=true; 3 public void run(){ 4 int i=0; 5 while(this.flag){ 6 while(true){ 7 System.out.println(Thread.currentThread().getName()+"运行,i="+(i++)); 8 } 9 }10 }11 p... 阅读全文
posted @ 2012-03-13 20:49 谈笑风生膜法师 阅读(285) 评论(0) 推荐(0)
摘要: 1 class ZhangSan{ 2 public void say(){ 3 System.out.println("Zhang said:you should lend your painting to me!"); 4 } 5 public void get(){ 6 System.out.println("Zhang has got it!"); 7 } 8 } 9 class LiSi{10 public void say(){11 System.out.println("Li said:yo... 阅读全文
posted @ 2012-03-13 20:06 谈笑风生膜法师 阅读(450) 评论(0) 推荐(0)
摘要: 1 class MyThread implements Runnable{ 2 private int ticket=5; 3 public void run(){ 4 for(int i=0;i<100;i++){ 5 synchronized (this){ 6 if(ticket>0){ 7 try{ 8 Thread.sleep(300); 9 }catch(Interr... 阅读全文
posted @ 2012-03-13 19:47 谈笑风生膜法师 阅读(543) 评论(4) 推荐(0)
摘要: 1 class MyThread implements Runnable{ 2 public void run(){ 3 for(int i=0;i<5;i++){ 4 try { 5 Thread.sleep(500); 6 } catch (Exception e){ 7 } 8 System.out.println(Thread.currentThread().getName()+"运行,i="+i); 9 }10 }11 }12 pu... 阅读全文
posted @ 2012-03-12 20:53 谈笑风生膜法师 阅读(279) 评论(0) 推荐(0)
摘要: 1 class MyThread implements Runnable{ 2 private String name; 3 public MyThread(String name){ 4 this.name=name; 5 } 6 public void run(){ 7 for(int i=0;i<10;i++){ 8 System.out.println(name+" 运行,i="+i); 9 }10 }11 }12 public class ThreadDemo {13 ... 阅读全文
posted @ 2012-03-12 19:51 谈笑风生膜法师 阅读(293) 评论(0) 推荐(0)
摘要: View Code 1 class MyThread extends Thread{ 2 private String name; 3 public MyThread(String name){ 4 this.name=name; 5 } 6 public void run(){ 7 for(int i=0;i<10;i++){ 8 System.out.println(name+"运行,i="+i); 9 }10 }11 }12 public class ThreadDemo {... 阅读全文
posted @ 2012-03-12 19:40 谈笑风生膜法师 阅读(164) 评论(0) 推荐(0)
摘要: 1 package hjwPackage; 2 3 public class hjwClass { 4 public static int add(int i,int j){ 5 return i+j; 6 } 7 public static int sub(int i,int j){ 8 return i-j; 9 }10 public static int mul(int i,int j){11 return i*j;12 }13 public static int div(int ... 阅读全文
posted @ 2012-03-11 21:01 谈笑风生膜法师 阅读(190) 评论(0) 推荐(0)
摘要: 1 class MyException extends Exception{ 2 public MyException(String msg){ 3 super(msg); 4 } 5 } 6 public class ThrowsDemo { 7 public static void main(String args[]){ 8 try{ 9 throw new MyException("自定义异常"); 10 }catch (Exception e){11 ... 阅读全文
posted @ 2012-03-11 19:36 谈笑风生膜法师 阅读(248) 评论(0) 推荐(0)
摘要: 1 class Math{ 2 public int div(int i,int j) throws Exception{ 3 System.out.println("========计算开始======="); 4 int temp=0; 5 try{ 6 temp=i%j; 7 } catch(Exception e){ 8 throw e; 9 } finally{10 System.out.println("=========... 阅读全文
posted @ 2012-03-11 19:29 谈笑风生膜法师 阅读(176) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 13 下一页