Hi, the reason i block the thread is that i need wait the end of the
thread before execute other methods (delete synchronized data), if i
don't use block thread's method (join or synchronized), the delete
methods will be executed before the thread. That's why i block the
thread.

I just used your class, i got the same result as not using block
method, the delete method execute before my synchronize method.

PS, your UserTask class has a good documentation.

On 12 sep, 18:15, "Romain Guy" <[EMAIL PROTECTED]> wrote:
> Yes, but if you wait, you block. Don't block the UI thread :) It is
> much better to have the background thread post a message to a Handler
> when it's done. I suggest you to use this class to perform your
> threading 
> work:http://code.google.com/p/apps-for-android/source/browse/trunk/Photost...
>
>
>
> On Fri, Sep 12, 2008 at 12:40 AM, roland <[EMAIL PROTECTED]> wrote:
>
> > Thanks for response, is there some other ways to wait the end of a
> > thread?
>
> > On 11 sep, 17:50, "Romain Guy" <[EMAIL PROTECTED]> wrote:
> >> By calling join() on the UI thread, you are blocking the UI thread.
> >> It's as if you were not using a background thread. That's why the
> >> ProgressDialog cannot be displayed.
>
> >> On Thu, Sep 11, 2008 at 3:06 AM, roland <[EMAIL PROTECTED]> wrote:
>
> >> > Hello, i have a question of displaying a ProgressDialog by joining the
> >> > threads. In my application, i will synchronize data with the server,
> >> > and remove the synchronized data from database. The synchronization
> >> > takes long time, so i decide to display a progressdialog during this
> >> > process. Of course i use a new thread to deal the synchronization,
> >> > here is what i use for the first time:
>
> >> > syncProgressDialog = ProgressDialog.show(Function.getContext(),
> >> > "Please wait...", "Synchronizing application's data...", true, false);
>
> >> > new Thread(new Runnable() {
> >> >        public void run() {
> >> >                synchronize();
> >> >                syncProgressDialog.dismiss();
> >> >        }
> >> > }).start();
>
> >> > removeData();
>
> >> > The problem i met with this solution is the main thread didn't launch
> >> > this thread immediately, it called the removeData before the new
> >> > Thread. Apparently the main thread don't wait the new Thread finishes
> >> > before execute the following method. So i changed this solution to :
>
> >> > syncProgressDialog = ProgressDialog.show(Function.getContext(),
> >> > "Please wait...", "Synchronizing application's data...", true, false);
>
> >> > Thread thread = new Thread(new Runnable() {
> >> >        public void run() {
> >> >                synchronize();
> >> >                syncProgressDialog.dismiss();
> >> >        }
> >> > });
> >> > thread.start();
> >> > try {
> >> >        thread.join();
> >> > }
> >> > catch (InterruptedException e) {
> >> >        e.printStackTrace();
> >> > }
>
> >> > removeData();
>
> >> > I used the join method to wait the end of synchronize thread before
> >> > removeData, there is another problem comes, the ProgressDialog didn't
> >> > display on the screen. I tried use handler:
>
> >> > Thread thread = new Thread(new Runnable() {
> >> >        public void run() {
> >> >                synchronize();
> >> >                handler.post(new Runnable() {
> >> >                        public void run() {
> >> >                                removeDialog();
> >> >                        }
> >> >                });
> >> >        }
> >> > });
>
> >> > private void removeDialog() {
> >> >        syncProgressDialog.dismiss();
> >> > }
>
> >> > Nothing changed, could anyone show me a sample code to display the
> >> > ProgressDialog in a joined thread or tell me which part i didn't
> >> > implemented correctly.
>
> >> --
> >> Romain Guywww.curious-creature.org
>
> --
> Romain Guywww.curious-creature.org
--~--~---------~--~----~------------~-------~--~----~
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