锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲免费在线播放,久久精品国产亚洲AV香蕉,亚洲精华国产精华精华液网站http://www.tkk7.com/jasonwbd/category/36496.htmlFirst know how, Second know why !zh-cnSat, 06 Dec 2008 07:56:56 GMTSat, 06 Dec 2008 07:56:56 GMT60all method synchronizedhttp://www.tkk7.com/jasonwbd/articles/244760.html楸艱穬浜庢笂楸艱穬浜庢笂Sat, 06 Dec 2008 04:36:00 GMThttp://www.tkk7.com/jasonwbd/articles/244760.htmlhttp://www.tkk7.com/jasonwbd/comments/244760.htmlhttp://www.tkk7.com/jasonwbd/articles/244760.html#Feedback0http://www.tkk7.com/jasonwbd/comments/commentRss/244760.htmlhttp://www.tkk7.com/jasonwbd/services/trackbacks/244760.html 1 
 2 public class TT1 implements Runnable{
 3     int b = 10 ;
 4     
 5     public synchronized void m1(){
 6         b = 1000 ;
 7         try{
 8             Thread.sleep(5000) ;
 9         }catch(InterruptedException ex){
10             ex.printStackTrace() ;
11         }
12         System.out.println("m1 : b = " + b) ;
13     }
14     
15     public void m2(){
16         b = 2000 ;
17         System.out.println("m2 : b = " + b ) ;
18     }
19     
20     public void run(){
21             m1() ;
22     }
23     
24     public static void main(String[] args){
25         TT1 tt = new TT1() ;
26         Thread t= new Thread(tt) ;
27         t.start() ;
28         try{
29             Thread.sleep(1000) ;/*que din m1 method was running !*/
30         }catch(InterruptedException ex){
31             ex.printStackTrace() ;
32         }
33         tt.m2() ;
34     }
35 } result :
m2 : b = 2000
m1 : b = 2000

 1 
 2 public class TT1 implements Runnable{
 3     int b = 10 ;
 4     
 5     public synchronized void m1(){
 6         b = 1000 ;
 7         try{
 8             Thread.sleep(5000) ;
 9         }catch(InterruptedException ex){
10             ex.printStackTrace() ;
11         }
12         System.out.println("m1 : b = " + b) ;
13     }
14     
15     public synchronized void m2(){
16         b = 2000 ;
17         System.out.println("m2 : b = " + b ) ;
18     }
19     
20     public void run(){
21             m1() ;
22     }
23     
24     public static void main(String[] args){
25         TT1 tt = new TT1() ;
26         Thread t= new Thread(tt) ;
27         t.start() ;
28         try{
29             Thread.sleep(1000) ;/*que din m1 method was running !*/
30         }catch(InterruptedException ex){
31             ex.printStackTrace() ;
32         }
33         tt.m2() ;
34     }
35 }
result:
m1 : b = 1000
m2 : b = 2000


楸艱穬浜庢笂 2008-12-06 12:36 鍙戣〃璇勮
]]>
Thread method synchronizedhttp://www.tkk7.com/jasonwbd/articles/244756.html楸艱穬浜庢笂楸艱穬浜庢笂Sat, 06 Dec 2008 04:14:00 GMThttp://www.tkk7.com/jasonwbd/articles/244756.htmlhttp://www.tkk7.com/jasonwbd/comments/244756.htmlhttp://www.tkk7.com/jasonwbd/articles/244756.html#Feedback0http://www.tkk7.com/jasonwbd/comments/commentRss/244756.htmlhttp://www.tkk7.com/jasonwbd/services/trackbacks/244756.html 1 
 2 public class TT implements Runnable{
 3     int b = 10 ;
 4     
 5     public synchronized void m1() throws Exception{
 6         b = 1000 ;
 7         Thread.sleep(5000);
 8         System.out.println("m1 : b = " + b) ;
 9     }
10     
11     public void m2(){
12         System.out.println("m2 : b = " + b) ;
13     }
14     
15     public void run(){
16         try{
17             m1() ;
18         }catch(Exception ex){
19             ex.printStackTrace() ;
20         }
21     }
22     
23     public static void main(String[] args) throws Exception{
24         TT tt = new TT() ;
25         Thread t = new Thread(tt) ;
26         t.start() ;
27         Thread.sleep(2000) ;
28          tt.m2() ;
29     }
30 }

楸艱穬浜庢笂 2008-12-06 12:14 鍙戣〃璇勮
]]>
Thread DeadLock demohttp://www.tkk7.com/jasonwbd/articles/244755.html楸艱穬浜庢笂楸艱穬浜庢笂Sat, 06 Dec 2008 03:54:00 GMThttp://www.tkk7.com/jasonwbd/articles/244755.htmlhttp://www.tkk7.com/jasonwbd/comments/244755.htmlhttp://www.tkk7.com/jasonwbd/articles/244755.html#Feedback0http://www.tkk7.com/jasonwbd/comments/commentRss/244755.htmlhttp://www.tkk7.com/jasonwbd/services/trackbacks/244755.html 1 
 2 public class ThreadDeadLock implements Runnable{
 3     
 4     private int flag ;
 5     static Object o1 = new Object() ;
 6     static Object o2 = new Object() ;
 7     
 8     public void run(){
 9         System.out.println("flag = " + flag) ;
10         if(flag==1){
11             synchronized(o1){
12                 try{
13                     Thread.sleep(1000) ;
14                 }catch(InterruptedException ex){
15                     ex.printStackTrace() ;
16                 }
17                 synchronized(o2){
18                     System.out.println("Hello , I'm Thread t1, and I synchronized o2 !");
19                 }
20             }
21             
22         }
23         
24         if(flag==2){
25             synchronized(o2){
26                 try{
27                     Thread.sleep(1000);
28                 }catch(InterruptedException ex){
29                     ex.printStackTrace() ;
30                 }
31                 synchronized(o1){
32                 System.out.println("Hello , I'm Thread t2, and I synchronized o1 !") ;
33             }
34             }
35             
36         }
37     }
38     
39     public static void main(String[] args){
40         ThreadDeadLock dl1 = new ThreadDeadLock() ;
41         ThreadDeadLock dl2 = new ThreadDeadLock() ;
42         dl1.flag = 1 ;
43         dl2.flag = 2 ;
44         Thread t1 = new Thread(dl1) ;
45         Thread t2 = new Thread(dl2) ;
46         t1.start() ;
47         t2.start() ;
48     }
49 }

楸艱穬浜庢笂 2008-12-06 11:54 鍙戣〃璇勮
]]>
shut down Threadhttp://www.tkk7.com/jasonwbd/articles/244752.html楸艱穬浜庢笂楸艱穬浜庢笂Sat, 06 Dec 2008 03:34:00 GMThttp://www.tkk7.com/jasonwbd/articles/244752.htmlhttp://www.tkk7.com/jasonwbd/comments/244752.htmlhttp://www.tkk7.com/jasonwbd/articles/244752.html#Feedback0http://www.tkk7.com/jasonwbd/comments/commentRss/244752.htmlhttp://www.tkk7.com/jasonwbd/services/trackbacks/244752.html 1 import java.util.*;
 2 
 3 public class ThreadTest2{
 4     public static void main(String[] args){
 5         MyThread mt = new MyThread();
 6         mt.start();
 7         try{
 8             Thread.sleep(10000);
 9         }catch(InterruptedException ex){
10             
11         }
12         mt.shutDown();
13         //mt.interrupt();
14     }
15 }
16 
17 class MyThread extends Thread{
18     boolean flag = true;
19     public void run(){
20         while(flag){
21             System.out.println("==========" + new Date() + "===========");
22             try{
23                 sleep(1000);
24             }catch(InterruptedException ex){
25                 return ;
26             }
27         }
28     }
29     public void shutDown(){
30         flag = false;
31     }
32 }

楸艱穬浜庢笂 2008-12-06 11:34 鍙戣〃璇勮
]]>
Thread synchronized demohttp://www.tkk7.com/jasonwbd/articles/244751.html楸艱穬浜庢笂楸艱穬浜庢笂Sat, 06 Dec 2008 03:31:00 GMThttp://www.tkk7.com/jasonwbd/articles/244751.htmlhttp://www.tkk7.com/jasonwbd/comments/244751.htmlhttp://www.tkk7.com/jasonwbd/articles/244751.html#Feedback0http://www.tkk7.com/jasonwbd/comments/commentRss/244751.htmlhttp://www.tkk7.com/jasonwbd/services/trackbacks/244751.html 1 
 2 
 3 public class ThreadTest3 implements Runnable{
 4     
 5     Timer timer = new Timer();
 6     
 7     public static void main(String[] args){
 8         ThreadTest3 r1 = new ThreadTest3();
 9         Thread t1 = new Thread(r1);
10         Thread t2 = new Thread(r1);
11         
12         t1.setName("t1");
13         t2.setName("t2");
14         t1.start();
15         t2.start();
16     }
17     
18     public void run(){
19         timer.add(Thread.currentThread().getName());
20     }
21 }
22 
23 class Timer{
24     private static int num = 0;
25     public void add(String name){
26         synchronized(this){
27             num++ ;
28             try{
29                 Thread.sleep(1000);
30             }catch(InterruptedException ex){
31                 
32             }
33             System.out.println("===" + name + " shi di " + num + " ge fang wen Timer de Thread !");
34             }
35     }
36 }

楸艱穬浜庢笂 2008-12-06 11:31 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 亚洲a级在线观看| 国产aⅴ无码专区亚洲av| 亚洲免费福利视频| 亚洲精品在线免费观看| 四虎影视久久久免费| 国产jizzjizz免费视频| 久久久久久亚洲精品无码| 免费特级黄毛片在线成人观看| 色偷偷女男人的天堂亚洲网| 成人免费无码大片A毛片抽搐| 亚洲欧美日韩一区二区三区在线| 成年女人视频网站免费m| 久久水蜜桃亚洲AV无码精品| 四虎影视精品永久免费| a一级毛片免费高清在线| 日韩亚洲欧洲在线com91tv| 无码人妻一区二区三区免费看| 亚洲日韩中文字幕天堂不卡| 97无码免费人妻超级碰碰夜夜| 亚洲人成网站在线播放2019| 亚洲av高清在线观看一区二区| 亚洲a级在线观看| 韩国18福利视频免费观看| 暖暖免费中文在线日本| 精品国产免费观看久久久| 鲁啊鲁在线视频免费播放| 亚洲中文字幕无码久久2017| 免费A级毛片无码视频| 亚洲综合国产成人丁香五月激情| 五月婷婷亚洲综合| 无码成A毛片免费| 亚洲狠狠色丁香婷婷综合| 国产亚洲人成网站在线观看| 99久热只有精品视频免费看| 亚洲日韩国产一区二区三区在线| 亚洲?V乱码久久精品蜜桃 | 中文国产成人精品久久亚洲精品AⅤ无码精品| 成av免费大片黄在线观看| 亚洲伊人久久大香线蕉影院| 亚洲A∨精品一区二区三区| 毛片无码免费无码播放|