Code example for Thread

0
 
class Consumer implements Runnable {
  Q q;
  Consumer(Q q) {
    this.q = q;
    new Thread(this, "Consumer").start();
  } 
  public void run() { 
    while(true) { 
      if (q.get() == 4) break;
    } 
  } 
}