package SOFA.demos.logdemo;

/**
  * Generated by SOFA CodeGen
  * Implementation for ::CUNI::SOFA::demos::logdemo::Tester?nenya.ms.mff.cuni.cz!0
  * Friday, March 14, 2003 11:16:51 AM CET
  */

public class TesterImpl extends _BaseTesterImpl implements Runnable {

  Thread thr;
  boolean end;
  boolean stopped;

  public TesterImpl(SOFA.Component.DCUP.DCUPComponentManagerImpl cm) {
    super(cm);
  }
  
  public void start() throws SOFA.Component.ComponentLifecycleException {
    thr = new Thread(this);
    thr.start(); 
  }
  
  public void stop() throws SOFA.Component.ComponentLifecycleException {
    setEnd();
    Thread thr = Thread.currentThread();
    while (!isStopped()) {
      try {
        thr.sleep(100);
      } catch (InterruptedException e) {}
    }
  }
  
  public void store() throws SOFA.Component.ComponentLifecycleException {
  
  }
  
  public void restore() throws SOFA.Component.ComponentLifecycleException {
  
  }

  public void setEnd() {
    end = true;
  }

  public boolean isStopped() {
    return stopped;
  }

  public void run() {
    while (!end) {
      LogRequirement.log("Hello world");
      try {
        Thread.currentThread().sleep(1000);
      } catch (Exception e) {
        ;
      }
    }
    stopped = true;
  }
  
}
