title: Start one thread per each Method in Java
body: <p>I'm interested to have multiple threads in a program, and my requirement is to start up each method in a new thread.</p>
  
  <p>Suppose I have the following:</p>
  
  <pre><code>public class A
  {
    int val=0;
  
    public void foo() 
    {
      for(int j=0;j&lt;10;j++)
      { 
        val=j;
        Thread.Sleep(1000);
      }
    }
  
    public int boo()
    {  
      return val;
    }
  }
  </code></pre>
  
  <p>I want to create an object in this class in a separate class like this</p>
  
  <pre><code>public class B
  {
    A myA = new A();
    myA.foo();
    int ret=myA.boo();
  }
  </code></pre>
  
  <p>What i want is, when u call <code>foo()</code> and <code>boo()</code>, those two methods will have to run on separate threads. So i can use the updated value of <code>"val"</code> from the <code>boo()</code> method.</p>
  
  <p>Please be kind enough to give me some advices to overcome this problem.
  Thanks in advance..:)</p>