I have an android application in which I upload some data via json. I perform this process in a separate thread.
Question: Is there a way to know when this thread has ended successfully. So that I can call a toast saying all data sent.
Code
protected void sendJson(){
    if(isOnline()){ 
        Thread t = new Thread() {
            public void run() {
                Looper.prepare(); //For Preparing Message Pool for the child Thread
                HttpClient client = new DefaultHttpClient();
                HttpConnectionParams.setConnectionTimeout(client.getParams(), 100000); //Timeout Limit
                HttpResponse response;
                // JSONObject json = new JSONObject();
                try {
                    String URL  ="http://myservice.azurewebsites.net/Service/RegisterStudent";
                    HttpPost post = new HttpPost(URL);
                    JSONObject StudentData = new JSONObject();  
                    String android_id = Secure.getString(AdminSection.this.getContentResolver(),Secure.ANDROID_ID);
                    DBHelper db = new DBHelper(getApplicationContext());
                    List<StudentClass> StudentDataAll = db.getAllStudentData();
                    for(int iCount=0; iCount< StudentDataAll.size(); iCount++){
                        StudentClass objStudentClass= (StudentClass)StudentDataAll.get(iCount);
                        String sSingleStudentCompleteDetails= android_id +","+ objStudentClass.RegistrationId + "," + objStudentClass.Name + "," + objStudentClass.SchoolID + "," + objStudentClass.Class + "," + objStudentClass.RollNo + "," + objStudentClass.RegistrationDate;
                        String sSingleStudentCompleteResponse = "";      
                        String strStudentID = objStudentClass.RegistrationId;        
                        StudentIDForSave = strStudentID;
                        List<StudentResponse> StudentResponse = db.getStudentResponseOnStudentID(strStudentID);
                        for(int iOptionCount=0; iOptionCount<StudentResponse.size(); iOptionCount++){
                            StudentResponse objStudentResponse=StudentResponse.get(iOptionCount);
                            if(iOptionCount>0) 
                                sSingleStudentCompleteResponse += ",";
                            sSingleStudentCompleteResponse += objStudentResponse.QuestionID + "-" + objStudentResponse.OptionID;
                        }
                        StudentData.put("StudentDetails", sSingleStudentCompleteDetails);
                        StudentData.put("Responses", sSingleStudentCompleteResponse);
                        JSONObject finaldata = new JSONObject();
                        finaldata.put("RegisterStudentRequest", StudentData);
                        // Toast.makeText(getBaseContext(), finaldata.toString(), Toast.LENGTH_LONG).show();
                        StringEntity se = new StringEntity( finaldata.toString());  
                        se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
                        post.setEntity(se);
                        response = client.execute(post);
                        String jsonString = EntityUtils.toString(response.getEntity());
                        JSONObject resp = null;  
                        resp = new JSONObject(jsonString);
                        JSONObject UploadStudentDataResult = resp.getJSONObject("RegisterStudentResult");
                        String strMessage = UploadStudentDataResult.getString("IsUploaded");
                        // Toast.makeText(getBaseContext(), strMessage, Toast.LENGTH_LONG).show();
                        if (StudentIDForSave != null){
                            SQLiteDatabase db1;
                            ContentValues values = new ContentValues();
                            values.put(DBHelper.isUploaded, strMessage);
                            // Call update method of SQLiteDatabase Class and close after
                            // performing task
                            db1 = helper.getWritableDatabase();
                            db1.update(DBHelper.TABLEStudent, values, DBHelper.S_ID + "=?",
                            new String[] { StudentIDForSave});
                            db1.close();
                        }
                    }
                    // tvSetCount.setText("Data Uploaded Successfully");
                }catch(Exception e) {
                    e.printStackTrace();
                    //createDialog("Error", "Cannot Estabilish Connection");
                }
                Looper.loop(); //Loop in the message queue
            }
        };
        t.start();   
    }  
}