/** * posterization * * * @author Pat Troy: troy AT uic DOT edu */ import java.util.*; import java.awt.*; public class Synch5 extends Thread { private char value; private Object lock; public static void main(String[] args) { Object ll1 = new Object(); Object ll2 = new Object(); System.out.println ("Hello"); Synch5 tt = new Synch5('a', ll1); Synch5 tt2 = new Synch5('b', ll1); Synch5 tt3 = new Synch5('c', ll1); Synch5 tt4 = new Synch5('d', ll1); Synch5 tt5 = new Synch5('e', ll1); System.out.println ("Goodbye"); } public Synch5 (char ch, Object ll) { value = ch; lock = ll; start(); //if (ch == 'c') // printIt('d'); } public void run () { for (int i = 0; i < 4; i++) { printIt(value); printIt2(Character.toUpperCase(value) ); } } //public synchronized void printIt (char ch) public void printIt (char ch) { synchronized (lock) { int i,j; for (i = 0; i < 10; i++) { for (j = 0; j < 35; j++) System.out.print(ch); System.out.println(ch); } System.out.println(); } } public void printIt2 (char ch) { synchronized (lock) { int i,j; for (i = 0; i < 10; i++) { for (j = 0; j < 35; j++) System.out.print(ch); System.out.println(ch); } System.out.println(); } } }