Hi,
I'm really enjoying Mark's "Beginning Android" - everything is clear
and straight to the point.
I wonder why in the Threading example the "isRunning" flag wasn't
declared "volatile". The flag is used to stop a thread from another
thread.
In case you have the book (or even wrote it :) ) - it's on page 143.
In case you don't, the simplified version of the code goes like this:
public class fooBar extends Activity{
...
public void onStart() {
super.onStart();
// why not volatile?
boolean isRunning=false;
Thread BG=new Thread(new Runnable() {
public void run() {
try {
while(isRunning){
// Do something
}
}
catch (Throwable t) {
// Do something
}
});
isRunning=true;
background.start();
}
public void onStop() {
super.onStop();
isRunning=false;
}
}
I know, the code works on android, so what am I mising here?
Thanks
Alex
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en