Posts

Showing posts with the label extends

In multithreading, why the other threads are not working when I have paused one thread for execution

In multithreading, why the other threads are not working when I have paused one thread for execution I have three threads in my programming.According to the threading concept all the threads run asynchronously. So every thread is executed by the processor randomly. If I have just paused the execution of one thread by using thread.sleep() then other thread should work . Right?? And when the sleep time for the thread is over then it should again continue with its execution. But in my case when I am pausing one thread by using t2.sleep(10000) then all other threads are also getting paused. But they should have worked normally while the t2 thread is in wait.Can anyone tell me why is it so? import java.util.*; class square extends Thread { public int x; public square(int x) { this.x = x; } public void run() { System.out.println("Square of the number is " + x*x); } } class cube extends Thread ...