FileDocCategorySizeDatePackage
Sharing1.javaAPI DocExample5897Mon Apr 06 18:10:22 BST 1998None

TwoCounter

public class TwoCounter 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 TwoCounter(Container c)

  // Add the display components as a panel
  // to the given container:
     
    Panel p = new Panel();
    p.add(t1);
    p.add(t2);
    p.add(l);
    c.add(p);
  
Methods Summary
public 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 voidsynchTest()

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