android - Thread not terminating correctly, I think -


public string newuser = "false"; public double lat = 0.0, lon = 0.0; 

i have following function in android app (called when button clicked) starts thread:

public void signupfunction(view view) {     assignvalues();     string filledall = checkiffilled();     if (filledall.equals("true")) {     log.d("lifecycle", "calling thread..");      //my thread     new validatethread().start();      log.d("after thread start","this log call not occur");      if (newuser.equals("true")) {         toast.maketext(this, "please wait obtain location", toast.length_short).show();         getmylocationfunction();         } else {             return;         }     } } 

validatethread:

class validatethread extends thread {     public void run() {         log.d("lifecycle", "validatethread entered...");         try {                         newuser = "true";                         log.d("validatethread", "validated , found new user");         } catch (exception e) {             log.d("validatethread", "exception in validatethread: " + e.getmessage());         }     } } 

the thread runs correctly...but after last line, not go point of start. don't understand why happening because i've used threads before , work correctly.

i know can give getmylocation function inside thread need way.

i've searched similar questions none helped.. doing wrong here? in advance.

it's race. signupfunction should wait until validatethread decides whether or not set newuser = "true". race code may work sometimes, accident.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -