How to use single thread class for multiple web calls in android
<p>I've two buttons.i need to get two different web calls using two buttons.But need to use single thread through.If i use like below code.,the thread class didn't return json response.It returns null value.How could i resolve this issue?</p>

<p>MY Thread class:</p>

<p>public static json runDialogLogin(String URL) {</p>

<p>JSONObject json;</p>

<p>JSONParser jParser = new JSONParser();</p>

<pre><code>    new Thread() {
        public void run() {

            try {



    // getting JSON string from URL
    json = jParser.getJSONFromUrl(URL);



            } catch (Exception e) {

                e.printStackTrace();
            }


        }

    }.start();
    return json;
}
</code></pre>

<p>My Main class:</p>

<p>.....</p>

<pre><code>    @Override
public final void onClick(final View v) {
    switch (v.getId()) {
    case R.id.button1:
            json= runDialogLogin("My URL1");
            if(json!=null){
                Intent i=new Intent(this,result1.class);
                startActivity(i);

                case R.id.button2:
                json= runDialogLogin("My URL2");
                if(json!=null){
                Intent i=new Intent(this,result2.class);
                startActivity(i);
            }
        }
     }
</code></pre>
