Thread Runnable2913 - Java Quiz Question


What will be the output of the following program?

public class ThreadWithRunnable {
    public static void main(String[] args) {
        CounterClass thread1 = new CounterClass();
        thread1.startThread();
        CounterClass thread2 = new CounterClass();
        thread2.startThread();
        CounterClass thread3 = new CounterClass();
        thread3.startThread();
    }
}
class CounterClass implements Runnable {
    Thread thread;
    public static int count = 0;
    public void run() {
        System.out.println("Count = " + count++);
    }
    public void startThread() {
        thread = new Thread(this);
        thread.run();
    }
}


A
Count = 0
Count = 1
Count = 2
B
Count = 2
Count = 1
Count = 0
C
Count = 2
Count = 2
Count = 2
D
Output can not be determined
E
Compilation Error or Runtime Error