title: Java program is stuck on a specific thread
body: <p>I'm trying to create 2 threads that both have infinite loop and should be switching from each other. The problem is that I'm getting stucked in the first thread forever and no context switch is being happend. What is my mistake?
  I'm using java8 and Eclipse Juno.</p>
  
  <p>This is the 'Main' class:</p>
  
  <pre><code>public class Main {
  
      /**
       * @param args
       */
      public static void main(String[] args) 
      {
  
          test1 t = new test1();
          test2 t2 = new test2();
          t.run();
          t2.run();
  
          while(true)
          {
              System.out.println("text from main");
              try {
                  Thread.sleep(100);
              } catch (InterruptedException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
  
  
      }
  
  }
  </code></pre>
  
  <p>This is the 'test1' class:</p>
  
  <pre><code>public class test1 implements Runnable {
  
      public void run() 
      {
          while(true)
          {
              System.out.println("text from thread");
              try {
                  Thread.sleep(10000);
              } catch (InterruptedException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
  
      }
  
  }
  </code></pre>
  
  <p>This is the 'test2' class:</p>
  
  <pre><code>public class test2 implements Runnable {
  
      public void run() 
      {
          while(true)
          {
              System.out.println("text from thread2");
              try {
                  Thread.sleep(100);
              } catch (InterruptedException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
  
      }
  
  }
  </code></pre>