title: Piping data between threads with Java
body: <p>I am writing a multi-threaded application that mimics a movie theater.  Each person involved is its own thread and concurrency must be done completely by semaphores.  The only issue I am having is how to basically link threads so that they can communicate (via a pipe for instance).  </p>
  
  <p>For instance:</p>
  
  <p>Customer[1] which is a thread, acquires a semaphore that lets it walk up to the Box Office.  Now Customer[1] must tell the Box Office Agent that they want to see movie "X".  Then BoxOfficeAgent[1] also a thread, must check to make sure the movie isn't full and either sell a ticket or tell Customer[1] to pick another movie.</p>
  
  <p>How do I pass that data back and forth while still maintaining concurrency with the semaphores?</p>
  
  <p>Also, the only class I can use from java.util.concurrent is the <a href="http://download.oracle.com/javase/6/docs/api/index.html?java/util/concurrent/Semaphore.html" rel="nofollow">Semaphore</a> class.</p>