, , ; , [ ], , ; , , , :
public class Puzzle extends Thread {
static boolean keepRunning=true;
static int var=0;
public void run() {
while (keepRunning) {
var++;
}
}
public static void main(String[] args) {
Puzzle p=new Puzzle();
p.setPriority(Thread.MAX_PRIORITY);
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
p.start();
System.out.println("Background Thread started");
try { Thread.sleep(1000); } catch(Exception e) { ; }
while (var != var) {
System.out.println(" I am inside loop now! ");
}
keepRunning=false;
}
}
source
share