root / trunk / libraries / libUIComponent / src-test / org / gvsig / gui / beans / incrementableTask / testThread.java @ 11042
History | View | Annotate | Download (889 Bytes)
1 |
package org.gvsig.gui.beans.incrementableTask; |
---|---|
2 |
|
3 |
public class testThread { |
4 |
public class miThread1 extends Thread { |
5 |
public void run() { |
6 |
System.out.println("miThread1 begin"); |
7 |
for (int i=0; i<=10; i++) { |
8 |
System.out.println(i);
|
9 |
try {
|
10 |
Thread.sleep(500); |
11 |
} catch (InterruptedException e) { |
12 |
e.printStackTrace(); |
13 |
} |
14 |
} |
15 |
System.out.println("miThread1 end"); |
16 |
} |
17 |
} |
18 |
|
19 |
public testThread() {
|
20 |
System.out.println("testThread begin"); |
21 |
miThread1 a = new miThread1();
|
22 |
a.start(); |
23 |
while (true) { |
24 |
try {
|
25 |
Thread.sleep(250); |
26 |
} catch (InterruptedException e) { |
27 |
e.printStackTrace(); |
28 |
} |
29 |
System.out.println("isAlive(): " + a.isAlive()); |
30 |
if (!a.isAlive()) break; |
31 |
} |
32 |
System.out.println("testThread end"); |
33 |
} |
34 |
|
35 |
public static void main(String[] args) { |
36 |
System.out.println("main begin"); |
37 |
new testThread();
|
38 |
System.out.println("main end"); |
39 |
} |
40 |
|
41 |
} |