title: Using threads in Java to process array elements
body: <p>Give an list of integers ( positive and negative ) stored in an array. How do I check if the numbers are positive, negative or zero concurrently.</p>
  <p>I have thought of some possible ways of solving this:</p>
  <ul>
  <li>having three different methods that will be called form three different threads using <code>wait</code> and <code>notify</code>. ( works to some extent )</li>
  <li>having a single <code>synchronized</code> method and three different threads accessing it with a global counter. The threads communicate with each other. ( works to some extent )</li>
  <li>Giving the array in slices to threads. For example Thread 1 will work on half of the elements and Thread 2 on the other half. ( not implemented yet, not sure if this approach fits the definition of concurrent correctly ).</li>
  </ul>
  <p>Please keep in mind that this was given as a College Assignment.</p>
  <p>If someone would give some insights or thoughts on ways of solving this, would be very helpful.</p>
  <p>Edit:</p>
  <p>This was the exact question given. I tried to simplify it a little and approach it.</p>
  <p><strong>Write a Java program which first generates a set of random numbers and then determines negative, positive even, positive odd numbers concurrently.</strong></p>