title: Simple Traffic Light Simulation with Java Threads
body: <p>As the questions states, I am trying to make a very, very simple traffic light simulation of a four way intersection. What my problem is, is that I am using two different threads and trying to bounce back and forth between the two using wait and notify <em>while inside a for loop.</em> I have some psuedo code below.</p>
  
  <pre><code>public class Processor 
  {
      public static int CarCounter = 1;
  
      public void lightOneAndTwo() throws InterruptedException
      {
          synchronized(this)
          {
              for(int carsOne = 0; carsOne &lt; 50; carsOne++)
              {
                  //Light One----------------------------&gt;
  
  
                  //Light Two----------------------------&gt;
  
                  wait();
              }
          }
      }
      public void lightThreeAndFour() throws InterruptedException
      {
          Thread.sleep(1000);
  
          synchronized(this)
          {
              for(int carsTwo = 0; carsTwo &lt; 50; carsTwo++ )
              {
                  //Light Three----------------------------&gt;
  
                  notify();
  
              }
          }
      }
  }
  </code></pre>
  
  <p>But when I call notify, it does not reactivate the the first thread. Am I doing something wrong or is there a better way to do it?</p>