FileDocCategorySizeDatePackage
Sharing2.javaAPI DocExample5902Mon Apr 06 18:10:22 BST 1998None

TwoCounter2

public class TwoCounter2 extends Thread

Fields Summary
private boolean
started
private TextField
t1
private TextField
t2
private Label
l
private int
count1
private int
count2
Constructors Summary
public TwoCounter2(Container c)

     
    Panel p = new Panel();
    p.add(t1);
    p.add(t2);
    p.add(l);
    c.add(p);
  
Methods Summary
public synchronized voidrun()

    while (true) {
      t1.setText(Integer.toString(count1++));
      t2.setText(Integer.toString(count2++));
      try {
        sleep(500);
      } catch (InterruptedException e){}
    }
  
public voidstart()

    if(!started) {
      started = true;
      super.start();
    }
  
public synchronized voidsynchTest()

    Sharing2.incrementAccess();
    if(count1 != count2)
      l.setText("Unsynched");