Puzzle: Threads + Javap

How many times will the loop iterate?

public class TestThreads extends Thread {
    static int i = 0;

    public void run() {
        for( ; i < 5; i++) {
            System.out.println(getName() + " " + i);
        }
    }

    public static void main(String args []) {
        new TestThreads().start();
        new TestThreads().start();
    }
}

The (long) answer is here:

http://www.javaranch.com/journal/200607/ThreadsAndJavap.html

 

 

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com