JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java Certification  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 Re:準備SCJD的一些心得 [Re:systempanic]
systempanic





發文: 216
積分: 4
於 2004-12-29 23:00 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
有網友對我的測試thread/locking方式有興趣,我評估這個應該沒有違背
Sun的規定,所以我post出來,有興趣的人自行參考即可,不一定要照我的方法做~

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package suncertify.test;
 
import junit.framework.*;
import java.io.*;
import java.util.*;
 
import suncertify.db.*;
 
public class DataAdapterClient  {    
            
      
      public static void main(String[] args) throws Exception {
          
          DataAdapter da1 = new DataAdapter();
          DataAdapter da2 = new DataAdapter();
          DataAdapter da3 = new DataAdapter();
          
             String s1 = "00000001";
             String s2 = "00000002";
             String s3 = "00000003";
             String s4 = "00000004";
             String s5 = "00000005";
             String s6 = "00000006";
          
          String[] s7 = {"My Name S7","My Location S7","15","Y","$100.00","2004/12/12","MyOwner7"};
          String[] s8 = {"My Name S8","My Location S8","15","Y","$100.00","2004/12/12","MyOwner8"};
          String[] s9 = {"My Name S9","My Location S9","15","Y","$100.00","2004/12/12","MyOwner9"};
          String[] s10 = {"My Name SX","My Location SX","15","Y","$100.00","2004/12/12","MyOwnerX"};
          
          DataAdapterClient dac = new DataAdapterClient();
          
 
             RunnerBooking rb1= dac.new RunnerBooking(da1, 0, s1);
             RunnerBooking rb2= dac.new RunnerBooking(da2, 0, s2);
             RunnerBooking rb3= dac.new RunnerBooking(da3, 0, s3);
             RunnerBooking rb4= dac.new RunnerBooking(da1, 0, s4);
             RunnerBooking rb5= dac.new RunnerBooking(da2, 0, s5);
             RunnerBooking rb6= dac.new RunnerBooking(da1, 0, s6);
 
             RunnerBooking rb7= dac.new RunnerBooking(da1, 6, s1);
             RunnerBooking rb8= dac.new RunnerBooking(da2, 6, s2);
             RunnerBooking rb9= dac.new RunnerBooking(da3, 6, s3);
             RunnerBooking rb10= dac.new RunnerBooking(da1, 6, s4);
             RunnerBooking rb11= dac.new RunnerBooking(da2, 6, s5);
             RunnerBooking rb12= dac.new RunnerBooking(da1, 6, s6);
 
                    
             RunnerDelete rd1 = dac.new RunnerDelete(da2, 7);
             RunnerDelete rd2 = dac.new RunnerDelete(da3, 21);
          
          
             RunnerCreate rc1 = dac.new RunnerCreate(da1, s7);
             RunnerCreate rc2 = dac.new RunnerCreate(da2, s8);
             RunnerCreate rc3 = dac.new RunnerCreate(da1, s9);
             RunnerCreate rc4 = dac.new RunnerCreate(da3, s10);
 
              rb7.start();
              rb8.start();
              rb9.start();
              rb10.start();
              rb11.start();
              rb12.start(); 
              
    
              rd1.start();
              rd2.start();
          
              rc1.start();
              rc2.start();
              rc3.start();
              rc4.start();
     
              rb1.start();
              rb2.start();
              rb3.start();
              rb4.start();
              rb5.start();
              rb6.start(); 
                  
          
      }    
 
    class RunnerBooking extends Thread {
        
      private DataAdapter da;
      private String customerId;
      private int recNo;
      
      public RunnerBooking() {}
      
      public RunnerBooking(DataAdapter da, int recNo, String customerId) {
        super();
        this.da = da;
        this.recNo = recNo;
        this.customerId = customerId;
      }
              
      public void run(){
        //System.out.println("Thread: " + this);
        try {
          da.book(recNo,customerId);                    
        }
        catch (RoomAlreadyBookedException e) {
          System.out.println("The room is already booked for recNo="+recNo);       
        }
        catch (Exception e) {
           e.printStackTrace();
        }
      }
    }            
 
   class RunnerDelete extends Thread {
        
      private DataAdapter da;
      private int recNo;
      
      public RunnerDelete() {}
      
      public RunnerDelete(DataAdapter da, int recNo) {
        super();
        this.da = da;
        this.recNo = recNo;
      }
              
      public void run(){
        //System.out.println("Thread: " + this);
        try {
          da.delete(recNo);                    
        }
        catch (Exception e) {
           e.printStackTrace();
        }
      }
    }   
 
   class RunnerCreate extends Thread {
        
      private DataAdapter da;
      private String[] s;
      
      public RunnerCreate() {}
      
      public RunnerCreate(DataAdapter da,  String[] s) {
        super();
        this.da = da;
        this.s = s;
      }
              
      public void run(){
        //System.out.println("Thread: " + this);
        try {
          int recNo = da.create(s);  
          System.out.println("New Record created, recNo="+ recNo);                  
        }
        catch (Exception e) {
           e.printStackTrace();
        }
      }
    }   
 
      
}
 


systempanic edited on 2004-12-29 23:03
reply to postreply to post
NaN
話題樹型展開
人氣 標題 作者 字數 發文時間
22717 [精華] 準備SCJD的一些心得 systempanic 3148 2004-07-27 10:21
17858 Re:準備SCJD的一些心得 gitaman 80 2004-08-04 10:07
18555 Re:準備SCJD的一些心得 systempanic 400 2004-08-04 12:52
16276 Re:準備SCJD的一些心得 gitaman 373 2005-01-04 09:31
16005 Re:準備SCJD的一些心得 systempanic 489 2005-01-04 12:36
16009 Re:準備SCJD的一些心得 gitaman 244 2005-01-04 17:41
15866 Re:準備SCJD的一些心得 systempanic 571 2005-01-04 20:05
15843 Re:準備SCJD的一些心得 gitaman 15 2005-01-05 08:38
5642 Re:準備SCJD的一些心得 LKK388 22 2011-09-09 20:07
6191 Re:準備SCJD的一些心得 ha9016559 246 2011-11-30 00:06
17179 Re:準備SCJD的一些心得 RogerY2k 70 2004-09-16 08:46
16981 Re:準備SCJD的一些心得 EdwardC 915 2004-09-16 15:03
16642 Re:準備SCJD的一些心得 systempanic 611 2004-09-18 12:22
16667 Re:準備SCJD的一些心得 systempanic 493 2004-09-18 10:36
16775 Re:準備SCJD的一些心得 dtaun 33 2004-09-18 21:06
16763 Re:準備SCJD的一些心得 EdwardC 1460 2004-09-18 22:43
16754 Re:準備SCJD的一些心得 systempanic 803 2004-09-18 23:00
16617 Re:準備SCJD的一些心得 gitaman 341 2004-09-20 10:07
16931 Re:準備SCJD的一些心得 systempanic 989 2004-09-20 10:44
14010 Re:準備SCJD的一些心得 cvc 28 2006-08-20 15:12
15723 Re:準備SCJD的一些心得 systempanic 84 2006-10-21 12:27
18813 Re:準備SCJD的一些心得 anc 75 2004-10-13 01:54
16126 Re:準備SCJD的一些心得 systempanic 5102 2004-12-29 23:00
16521 Re:準備SCJD的一些心得 btsai 112 2005-01-01 12:35
» JWorld@TW »  Java Certification

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8