title: Problems using multithreading on C#
body: <p>I want to implement a program that shows some chars moving randomly on console, each of them with different speed.</p>
  
  <p>I created a recursive method that moves one letter randomly on console. When I want to move two letters I use two threads calling the same method.</p>
  
  <p>The program works perfectly the first minutes, but after some time the letters began to appeare everywhere on console!</p>
  
  <p>I'm really sure that my recursive method is okay (I even try to create another method, this time just using a while(i&lt;100000) instead of recursion. But the same error appeared). Could someone help me with this?</p>
  
  <p>Thank you very much.</p>
  
  <p>EDIT: Sorry, here's a sample-code (don't consider what happen if the letters take the same position). The letters move on a 'stadium' they move between 20 - 51 in the x axis and 5 - 26 in the y axis.</p>
  
  <pre><code>public void WriteAt(string s, int x, int y)
      {
          try
          {
              Console.SetCursorPosition(x, y);
              Console.Write(s);
          }
          catch (ArgumentOutOfRangeException e)
          {
              Console.Clear();
              Console.WriteLine(e.Message);
          }
  
      }
  
      public void impresion()
      {
          int x = random.Next(20, 51);
          int y = random.Next(5, 26);
          WriteAt("A", x, y);
          imprimir("A", x, y, 80);
      }
  
      public void impresion2()
      {
          int x = random.Next(20, 51);
          int y = random.Next(5, 26);
          WriteAt("E", x, y);
          imprimir2("E", x, y, 20);
      }
  
      public void go()
      {
          Thread th1 = new Thread(impresion);
          Thread th2 = new Thread(impresion2);
          th1.Start(); //creates an 'A' that will move randomly on console
          th2.Start(); //creates an 'E' that will move randomly on console
      }
  
      public void imprimir(string s, int x, int y, int sleep)
      {
          Thread.Sleep(sleep);
          WriteAt(" ", x, y);
          int n = random.Next(1, 5);
  
          if (n == 1)
          {
              if ((x + 1) &gt; 50)
              {
                  WriteAt(s, x, y);
                  imprimir(s, x, y, sleep);
              }
              else
              {
                  WriteAt(s, x + 1, y);
                  imprimir(s, x + 1, y, sleep);
              }
          }
  
          else if (n == 2)
          {
              if ((y - 1) &lt; 5)
              {
                  WriteAt(s, x, y);
                  imprimir(s, x, y, sleep);
              }
              else
              {
                  WriteAt(s, x, y - 1);
                  imprimir(s, x, y - 1, sleep);
              }
          }
  
          else if (n == 3)
          {
              if ((x - 1) &lt; 20)
              {
                  WriteAt(s, x, y);
                  imprimir(s, x, y, sleep);
              }
              else
              {
                  WriteAt(s, x - 1, y);
                  imprimir(s, x - 1, y, sleep);
              }
          }
  
          else
          {
              if ((y + 1) &gt; 25)
              {
                  WriteAt(s, x, y);
                  imprimir(s, x, y, sleep);
              }
              else
              {
                  WriteAt(s, x, y + 1);
                  imprimir(s, x, y + 1, sleep);
              }
          }
      }
  </code></pre>