public class IkiIsikKontroluThread extends Thread {
  double kirmiziZaman = 5.0;
  double yesilZaman = 4.0;
  IkiTrafikIsigi ti;
  int isikNo;
   public IkiIsikKontroluThread(IkiTrafikIsigi tiparam, int isikNo)
   {
     ti = tiparam;
     this.isikNo = isikNo;
   }
  public void run()
  {
    char which = '\0';
    try {
      Thread.sleep( (int)( Math.random()*1000 ) );
    }
    catch( InterruptedException interruptedEx ) {
      interruptedEx.printStackTrace();
    }
    while(true)
    {
     which = ti.which_light[ isikNo ];
     //12 saniye bekle
     try {
       switch ( which ) {
         case 'y' : ti.which_light[ isikNo ] = 'r';
                    ti.repaint();
                    break;
         case 'g' : ti.which_light[ isikNo ] = 'y';
                    ti.repaint();
                    Thread.sleep( 1000 );
                    ti.kontrolBirak();
                    break;
         case 'r' : ti.kontrolAl();
                    ti.which_light[ isikNo ] = 'g';
                    ti.repaint();
                    Thread.sleep((int)(yesilZaman*1000));
                    break;
       }
     }
     catch(InterruptedException e)
     {System.err.println(e.toString());}
    }
  }

  public void setKirmiziZaman(double zi)
  {
    kirmiziZaman=zi;
  }
  public double getKirmiziZaman()
  {
    return kirmiziZaman;
  }
  public void setYesilZaman(double zi)
  {
    yesilZaman=zi;
  }
  public double getYesilZaman()
  {
    return yesilZaman;
  }
}

