• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Simple Thread Question

Why is it that this does not work? It will stop as soon as it gets to "myProgress.setVisibility(8);". If I add a handler.post() it will work, but I just do not understand why it will not work by itself. Any help would be greatly appreciated.
(BTW myProgress is just a progress bar and is intended to disappear after 5 seconds)

new Thread(new Runnable() {

public void run() {
while (progress < 10){
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
progress++;
}
myProgress.setVisibility(8);

}
}).start();
 
Back
Top Bottom