Siemens XT65 User Manual page 122

Siemens cell phone accessories user manual
Hide thumbs Also See for XT65:
Table of Contents

Advertisement

Java User's Guide
13.2 Programming the MIDlet
122
/* Print loop counter and wait 1 second,
* do something useful here instead */
System.out.println("Thread(" + loops + "): Loop " + i);
try {
Thread.sleep(1000);
} catch(InterruptedException e) {
System.out.println(e);
}
}
System.out.println("Thread(" + loops + "): Finished naturally");
}
}
/**
* ThreadDemo - constructor
*/
public ThreadDemo() {
System.out.println("ThreadDemo: Constructor, creating threads");
thread1 = new DemoThread(2);
thread2 = new DemoThread(6);
}
/**
* startApp()
*/
public void startApp() throws MIDletStateChangeException {
System.out.println("ThreadDemo: startApp, starting threads");
thread1.start();
thread2.start();
System.out.println("ThreadDemo: Waiting 4 seconds before stopping threads");
try {
Thread.sleep(4000);
} catch(InterruptedException e) {
System.out.println(e);
}
destroyApp(true);
System.out.println("ThreadDemo: Closing application");
}
/**
* pauseApp()
*/
public void pauseApp() {
System.out.println("ThreadDemo: pauseApp()");
}
/**
* destroyApp()
*/
public void destroyApp(boolean cond) {
System.out.println("ThreadDemo: destroyApp(" + cond + ")");
System.out.println("ThreadDemo: Stopping threads from outsdide");
runThreads = false;
try {
System.out.println("ThreadDemo: Waiting for threads to die");
thread1.join();
thread2.join();
} catch(InterruptedException e) {
System.out.println(e);
}
System.out.println("ThreadDemo: All threads died");
notifyDestroyed();
}
}
wm_java_usersguide_v12
Confidential / Released
Page 122 of 123
s
2008-02-25

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ac65Ac75Xt75Tc65

Table of Contents