whaaa... thats really going against all the basic android fundamentals. ..

first, you never ever stop/hault/wait/busy-wait/do long processes on the UI 
(what you called Main) thread. You do that, the app is stuck and eventually 
errors out to the user (an ANR).
Second, you shouldn't be creating UI on a background thread (can be done 
under certain strict conditions, but not recommended). Any code that 
'touches' the UI, needs to run on the UI thread.

Look up for tutorials regarding using ASyncTasks... also, i think you 
skipped on reading the Android Fundamentals articles... you should read 
those :)

On Friday, November 30, 2012 4:20:06 AM UTC-5, Mr cool wrote:
>
> i have one problem with handling the thread in android ,in my class i have 
> to create one thread which create some UI after that thread finish i will 
> get some value ,here i want to wait my Main Process until the thread 
> complete it process but when i put wait() or notify in Main process  thread 
> does not show the  UI  in my application
>
> this is sample code
>
>     protected void onCreate(Bundle savedInstanceState) {
>     
>      downloadThread = new MyThread(this);
>     downloadThread.start();
>     
>     synchronized(this){  
>     try {
>     this.wait();
>     } catch (InterruptedException e) {
>     // TODO Auto-generated catch block
>     e.printStackTrace();
>     }
>     }
>     
>      String test=Recognition.gettemp();
>     public class MyThread extends Thread {
>     private Recognition recognition;
>     
>     public MyThread(Recognition recognition) {
>     this.recognition = recognition;
>     // TODO Auto-generated constructor stub
>     }
>     
>     @Override
>     public void run() {
>     synchronized(this)
>
>     {                
>                                                    
>     handler.post(new MyRunnable());
>     
>     }
>     
>     notifyAll();
>     }
>     }
>     }
>     static public class MyRunnable implements Runnable {
>     public void run() {
>     settemp(template);
>     }
>     
>     }
>     }
>     
>     public static String gettemp() {
>     return template;
>     }
>     public static void settemp(String template) {
>     Recognition.template = template;
>     }
>     
>     }
> here i will not use AsynTask because i have some other issue that is 
> reason i choose Thread even now the problem is Thread wait do any give the 
> suggestion for this
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to