multithreading - Thread synchronization in android -


hi have 2 functions first called simulation() : it's containig thread changes variables

public void simulation() {     ambienttemp = 20;     engtemp = 20;     mileage = 123456;     fuel = 100;      thread = new thread()     {         public void run()         {             (int i=0; i<l; i++)             {                 system.out.println(i);                 try {                     thread.sleep(1);                 }                 catch (interruptedexception e)                 {                     e.printstacktrace();                 }                     speed = speed[i];                     revs = engspeed[i];                 ......                 uicallback.sendemptymessage(0);        }     };     thread.start(); } 

the second function used chane ui :

 public handler uicallback = new handler () {     public void handlemessage (message msg)     {         if (d) log.i(tag, "run() -> handler");         menu1_fragment f1 = new menu1_fragment();         menu2_fragment f2 = new menu2_fragment();         menu3_fragment f3 = new menu3_fragment();         transaction = getfragmentmanager().begintransaction();         system.out.println("update ");         if (d) log.i(tag, "run() -> logicanalizerview - transaction.replace(r.id.fragment_content, tachofrag)");         if (tachofrag != null && tachofrag.isvisible())         {             view o1 = findviewbyid(r.id.progressbar4);             f1.setrevs(o1,revs);              .....             transaction.replace(r.id.container, f1);             transaction.commit();             } 

but unfortonatly ui not changing should .... have idea ... , how can fix