i have class that extends thread and in one of its methodes i added Thread.sleep(5000) to wait for something, and i start this thread from onCreate() like this
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MyClass mc = MyClass();
mc.start();
mc.join();
// do something
}
and in the MyClass run methode i do something like this
Class MyClass extends Thread {
public void run() {
sleep(15000);
// do something
}
}
the problem that i see the UI thread sleep for 5 second too if i run MyClass thread (that calls the sleep methode), why this happens ?
Well, here’s you problem:
This makes the current thread (i.e. the UI) wait until the thread represented by
mchas finished itsrun()method. What were you trying to achieve with thejoin()anyway.