import element.*; public class UnsynchThread extends Thread { private static int ticker = 0; static public int count() // post: return a unique counter value { int result = ticker; yield(); ticker++; yield(); return result; } public void run() // post: print counter values until one larger than 10 is printed { int ticket; do { ticket = count(); System.out.println(ticket); } while (ticket < 10); } public static void main(String args[]) // post: run five threads that fight over the counter { int i; for (i = 0; i < 5; i++) { new UnsynchThread().start(); } } } /* 0 0 0 0 0 5 5 5 5 5 10 10 10 10 10 */