title: Showing a simple example of deadlock with semaphores
body: <p>I'm currently taking Operating Systems and our teacher assigned this problem for our lab but he's not very helpful.  So I need to show a basic example of deadlock with semaphores and my output needs to demonstrate the occurence of the deadlock.  I'm assuming he means if my exception is caught.  This is as close as I've gotten.  </p>
  
  <pre><code>import java.util.concurrent.Semaphore;
  public class deadlockTest2
  {
      private Semaphore sem1=new Semaphore(1);
      private Semaphore sem2=new Semaphore(1);
      private int num;
  
      public deadlockTest2(int random)
      {
              num=random;
      }
      public void run()
      {
          try 
          {
              sem1.acquire();
          }
           catch (InterruptedException e)
          {
              System.out.println("I am deadlocked");}
          }
  
      public static void main(String[] args)
      {
          deadlockTest2 tester=new deadlockTest2(5);
          deadlockTest2 tester2=new deadlockTest2(20);
          tester.run();
          tester2.run();
      }   
  }
  </code></pre>
  
  <p>~<br>
  ~<br>
  Am I even close? I keep reading material but not fully grasping it.  I think I don't understand what a process is.  Someone please help.</p>