title: Having 1 thread execute multiple methods at the same time
body: <p>So I have a list with 900+ entries in C#. For every entry in the list a method has to be executed, though these must go all at the same time. First I thought of doing this:</p>
  
  <pre><code>public void InitializeThread()
  {
     Thread myThread = new Thread(run());
     myThread.Start();
  }
  
  public void run()
  {
     foreach(Object o in ObjectList)
     {
        othermethod();
     }
  }
  </code></pre>
  
  <p>Now the problem here is that this will execute 1 method at a time for each entry in the list. But I want every single one of them to be running at the same time.</p>
  
  <p>Then I tried making a seperate thread for each entry like this:</p>
  
  <pre><code>public void InitializeThread()
  {
     foreach(Object o in ObjectList)
     {
        Thread myThread = new Thread(run());
        myThread.Start();
     }
  }
  
  public void run()
  {
     while(//thread is allowed to run)
     {
        // do stuff
     } 
  } 
  </code></pre>
  
  <p>But this seems to give me system.outofmemory exceptions (not a suprise since the list has almost a 1000 entries.
  Is there a way to succesfully run all those methods at the same time? Either using multiple threads or only one?</p>
  
  <p>What I'm ultimately trying to achieve is this: I have a GMap, and want to have a few markers on it. These markers represent trains. The marker pops up on the GMap at a certain point in time, and dissappears when it reaches it's destination. All the trains move about at the same time on the map. </p>
  
  <p>If I need to post more of the code I tried please let me know.
  Thanks in advance!</p>