Thread handling problem in Android Junit Test Case
<p>I am implementing a testcase in Android Juint. I am facing problem in
handling threads. After the successful running of a test case, it will
not wait for child thread to be finished. e.g. If one testcase call
some services in server. testcase will successfully send request to a
server, but it will not wait for a response. Because testcase will
start this request in a different Thread. Currently I am using
following code,</p>

<pre><code>   currentThread = Thread.currentThread();
   synchronized (Thread.currentThread()) {
           try {
                              Thread.currentThread().wait();
                   } catch (InterruptedException e) {
                           // TODO Auto-generated catch block
                           e.printStackTrace();
                   }
</code></pre>

<p>After getting response I am using the following code to start the
current thread again.</p>

<pre><code>  currentThread.interrupt();
</code></pre>

<p>I think this is not the good way to do it. There must be a some other
technique to handle this problem properly. Please let me know as soon
as possible if any one knows solution for this.</p>

<p>Thanks,</p>

<pre><code> Vashishta
</code></pre>
