This is my code for running a background thread.  I believe it is very poor in naming and code structure.package com.ocs.socialshare.bloggershare;import android.app.Activity;import android.os.Bundle;import android.view.Menu;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.EditText;import com.google.gdata.util.AuthenticationException;public class MainActivity extends Activity implements OnClickListener{    private Thread doinBackground;    private EditText username,password,blogurl;    private Button login;    private String user,pass,bloglink;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        findViewById();        setOnclickListenerRegister();    }    private void findViewById() {        // TODO Auto-generated method stub        username        =   (EditText) findViewById(R.id.username);        password        =   (EditText) findViewById(R.id.password);        blogurl         =   (EditText) findViewById(R.id.blogurl);        login           =   (Button) findViewById(R.id.login);    }    private void setOnclickListenerRegister() {        // TODO Auto-generated method stub        login.setOnClickListener(this);    }    private void blogShare(final String user,final String pass,final String bloglink) {        // TODO Auto-generated method stub            doinBackground =new Thread(new Runnable()             {                @Override                public void run()                 {                // TODO Auto-generated method stub                BloggerClient blog = new BloggerClient(getApplicationContext());                try {                    blog.oAuthBlogger(user,pass,bloglink);                    }                     catch (AuthenticationException e)                     {                    // TODO Auto-generated catch block                    e.printStackTrace();                    }                }            });        doinBackground.start();    }    @Override    public boolean onCreateOptionsMenu(Menu menu) {        // Inflate the menu; this adds items to the action bar if it is present.        getMenuInflater().inflate(R.menu.main, menu);        return true;    }    @Override    public void onClick(View view) {        // TODO Auto-generated method stub        int viewid  = view.getId();        if(viewid == R.id.login)        {        validateFeild();        blogShare(user,pass,bloglink);        }    }    private void validateFeild() {        // TODO Auto-generated method stub        user        =    username.getText().toString();        pass        =    password.getText().toString();        bloglink    =    blogurl.getText().toString();    }}
Android Thread and Runnable
java;beginner;android
The first thing I would say is to use an AsyncTask here instead of normal Thread/Runnable. AsyncTask helps you to work better with the thread and UI thread better.It's a login system,  so disable login buttons while the application is login to avoid the user to press multiple times on Login.http://developer.android.com/reference/android/os/AsyncTask.html