You need to pass the ThreadExample instance to the Thread constructor to tell the new thread to start:
Thread t = new Thread(new ThreadExample()); t.start();
(Unfortunately, the Thread class was poorly designed in various ways. It would be more useful if it did not have a run() method, but made you pass Runnable to the constructor, then you would find the problem at compile time.)
source share