public class Broken implements Runnable { boolean stop=false; public void run() { System.out.println("Entering run()"); while(!stop) {} System.out.println("Finished run()"); } public static void main(String[] args) { Broken broke=new Broken(); Thread thread=new Thread(broke); thread.start(); long startTime=System.currentTimeMillis(); while(System.currentTimeMillis()-startTime<3000) ; //not the most efficient way to wait System.out.println("Time's up; stop the thread"); broke.stop=true; System.out.println("Finished main()"); } }