class MyThread extends Thread { int count; MyThread(String name) { super(name); // jmeno vlakna count = 0; start(); // start } public void run() { System.out.println(getName() + " startuje"); try { do { Thread.sleep(500); System.out.println("V " + getName() + ", citac je " + count); count++; } while(count < 5); } catch(InterruptedException exc) { System.out.println(getName() + " preruseno"); } System.out.println(getName() + " konci"); } } class DediThread { public static void main(String args[]) { System.out.println("Hlavni vl.startuje"); MyThread mt = new MyThread("potomek"); do { System.out.print("."); try { Thread.sleep(100); } catch(InterruptedException exc) { System.out.println("Hlavni vl. preruseno."); } } while (mt.count != 5); System.out.println("Hlavni vl. konci"); } }