I have one class DataThread
inherited from Thread.
I am using two DataThread
objects ReadThread
and WriteThread
.
I have another thread where Main_GUI
is running.
Now when I press a button on main_GUI
it calls a method x.method1()
and then this method uses the WriteThread method WriteThread.sleepForReset(). In
public void sleepForReset(){
try {
sleep(28000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
When I press the button on main_GUI
the GUI stalls for 28000
miliseconds.
If I am calling sleep on WriteThread
then why it halts the main_GUI
?
Is it because the sleep is a static method? If yes can anybody suggest how to sleep the WriteThread
without affecting Main_GUI
?
Thanks all of you for suggesting me different options..... But I used TimeTask.schedule() and worked. I scheduled my job for later instead of using sleep in the current thread......