Search code examples
javamultithreadingjava-threads

There is no console output from thread. Thread doesn't work?


class myRunnable implements Runnable {

    public void run() {
        // TODO Auto-generated method stub
        System.out.println("run");
    }

}

public class TestThread {

    public static void main(String[] args) {
        Runnable threadJob = new myRunnable();
        Thread t = new Thread(threadJob);
        t.start();
        for (int i = 0; i < 100000; i++) {
            System.out.println("main");
        }

    }
}

Result in the console:

main main main main ... main main main main

I can't find any "run" word, this means the run method didn't run. Can somebody explain that for me. Thank you.

PS: when i<10, i<100, i<1000, i<10000, I can find the "run" word, but when i<100000 then I can't find the "run" word, that's just weird

enter image description here


Solution

  • Run has been printed out. But your console-buffer is not large enougth.

    Change the Console-configuration to unlimited buffer.enter image description here