public class Main extends Thread {
private int a;
public Main() {
a = 2;
start();
System.out.println(a);
}
public void run() {
a++;
}
public static void main( String[] args ) {
new Main();
}
}
The start() method creates new thread and calls the run() method.
Actually, start() method tells to scheduler to create and run a new thread.
But it's unknown when the execution will start.
So the answer is 'the result is undetermined as it may vary from one execution to another'.
Ввійдіть щоб вподобати
Ввійдіть щоб прокоментувати