title: Create array in main and fill it with data from seperate threads
body: <p>Okay so I am having trouble with this maybe i have just been thinking too long or am dumb but here is what i have and what i am trying to do:</p>
  
  <p><strong>Update- code all fixed no more run problems.</strong></p>
  
  <pre><code>public class myClass program {
     int [] w = null;
     int [] x = null;
     Thread T = null;
     public static void main(String [] args){
      x = new int[5];
      w = new int[5];
  
   // here i am trying to invoke a new thread passing the index
   // of my array, then incrementing the index each time i create a new thread
   // the purpose is to fill each index each time the new thread runs.
  
      for(int i = 0; i &lt; w.length; i ++){
        // T = new Thread(new myThreadClass(w[i])); // only passes 0 take this out and 
        T = new Thread( new myThreadClass(i));      // pass i so the position changes
        T.start();
        try{
          Thread.sleep(100);
          }catch(Exception e){}
  
     }
  }
  </code></pre>
  
  <p>in my separate class myThreadClass.java i have the following:</p>
  
  <pre><code>public class myThreadClass extends Thread{
   int [] w = null;
   int position = 0;
   int value = 1;
  
    public myThreadClass(int p){
      this.position = p
      w = myClass.w;
    }
  
    @Override
    public void run(){
     // synchronize the thread so there is no memory cache problems
     //
     synchronized(w){
        w[position] = value;
     }
    }
  
  }
  </code></pre>
  
  <p>when i print out the output of w from myClass:</p>
  
  <p>i get <code>w = 1 0 0 0 0</code> </p>
  
  <p>but i want <code>w = 1 1 1 1 1</code></p>
  
  <p><strong>EDITED- i am now getting the right output - check the code for changes</strong></p>