Getting run time error while using thread handler and message object
<p>I wrote a simple program on thread handlers.
When the button is clicked the action is handled in a new thread.
But the operating system is closing my application when the button is clicked.
Please help me in debugging this code.
Thanks in advance.</p>

<pre><code>package example.practice.handlerthread;

 import android.app.Activity;
 import android.content.Context;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.HandlerThread;
 import android.os.Looper;
 import android.os.Message;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.Button;
 import android.widget.Toast;

 public class HandlerthreadActivity extends Activity {

Button s;String n;
Context c=this;
private final class myhandler extends Handler
{
public myhandler(Looper loop)
{
    super(loop);
    Toast.makeText(c, "handler initiated", Toast.LENGTH_SHORT).show();
}
public void handleMessage(Message msg)
{
    String ="hi";

    setname();
}

}
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
   s=(Button)findViewById(R.id.button1);
    HandlerThread td=new HandlerThread("hellohandler");
    td.start();
    Looper l=td.getLooper();
    final myhandler m=new myhandler(l);

   s.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        // TODO Auto-generated method stub
       Message msg=m.obtainMessage();
       msg.arg1=12999093;
       //Toast.makeText(c, "in handlemsg func", Toast.LENGTH_LONG).show();
       m.sendMessage(msg);
    }
});
}
void setname()
{

    s.setText(n);
}
}
</code></pre>
