When I start some thread in my program, everything else stops.
This is my theme code ...
static Thread b1 = new Thread(new Builders());
b1.run();
System.out.println("done");
This is a class Builders.
public class Builders implements Runnable {
static boolean busy=false;
Random r = new Random();
public void run() {
try{
busy=true;
System.out.println("ready");
Thread.sleep(9999);
busy=false;
System.out.println("done");
}
catch(Exception e){
}
}
}
When I run the program, the thread starts and the program waits for the end of the thread. I thought that the main theme of threads is that code can work simultaneously. Can someone please help me understand what I'm doing wrong.
source
share