title: How to use semaphores without using if-else, while, for, etc
body: <p>This is homework, but I'm just looking for a nudge in the right direction (not someone to do my work for me).</p>
  
  <ul>
  <li>I have four threads</li>
  <li>They each print out their own numbers in a loop: 1's, 2's, 4's, and 8's respectively</li>
  <li>At the beginning of my main I must start all four threads and then end them after 500ms</li>
  <li>I am to use semaphores in order to ensure that only these numbers are printed in this repeating pattern: 111111112222448111111112222448111111112222448……</li>
  <li>I am not to use while, for, if, else, and so forth.</li>
  <li>I am using Java</li>
  </ul>
  
  <p>I do not know how to definitively get that pattern to print out without using if statements and I am very unfamiliar with semaphores and only a little familiar with threading. </p>
  
  <p>Could a kind soul give me some direction? Even if you simply point me to a wonderful video or article, I'll be appreciative.</p>
  
  <p><em>EDIT</em>: I'm sorry. I've made things confusing. There are already while statements defined for me inside each thread. Each while statement only prints one of its numbers at a time. Ex: It prints a "1" not a "11111". It's that I am not allowed to define any <em>more</em> while statements and such.</p>