Probleem: de stopwatch stopt niet (ofwel de thread stopt niet met runnen)
En er is geen thread.stop functie aanwezig in Java Mobile, dus heb het geprobeerd met een boolean alleen hoe kan de boolean veranderen als de 2e thread geheel bezig is?
Versimpelde code;
En er is geen thread.stop functie aanwezig in Java Mobile, dus heb het geprobeerd met een boolean alleen hoe kan de boolean veranderen als de 2e thread geheel bezig is?
Versimpelde code;
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| public void commandAction(Command c, Displayable s) {
if (c == mExitCommand){
destroyApp(false);
notifyDestroyed();
}
else if (c == mStartCommand){
Starttime =System.currentTimeMillis() ;
UpdateTimer Utimer = new UpdateTimer();
secondThread = new Thread( Utimer );
secondThread.start();
}
else if (c == mStopCommand){
Running = false;
}
public class UpdateTimer implements Runnable {
public void run(){
Running = true;
while (Running = true) {
//Time Stuff
} |
[ Voor 90% gewijzigd door Calvin&Hobbes op 04-07-2008 22:10 ]