Java Reference
In-Depth Information
38.
display.setText("Working "+i);
39.
try {
40.
Thread.sleep(500);
41.
} catch (Exception ex){
42.
ex.printStackTrace();
43.
}
44.
}// for i
45.
display.setText("Done");
46.
}
47.
48.
public static void main(String[] args){
49.
System.out.println("Running in thread "+
Thread.currentThread().getName());
50.
NonBlockingFrame nbf = new NonBlockingFrame();
nbf.showIt();
51.
}
52.
53.
54.
// Internal class
55.
56.
class MenuListener implements ActionListener{
57.
58.
public void actionPerformed(ActionEvent evt){
59.
60.
String command = evt.getActionCommand();
61.
if (command.equals("Start")){
62.
// The worker thread is created and started
63.
Thread worker = new WorkerThread();
64.
worker.start();
65.
}
66.
else
67.
{
68.
System.out.println("Unknown ActionCommand");
69.
System.exit(0);
70.
}
71.
}
72.
73.
}// internal class
74.
75.
// Internal class
76.
77.
class WorkerThread extends Thread{
int num;
78.
public WorkerThread(){
79.
nummer++;
80.
81.
num = nummer;
82.
}
83.
Search WWH ::




Custom Search