Just use HandlerThread to have a single thread sitting there
processing messages that you send to it.  Even better, create the
thread in onStart() and quit it in onStop().

On Oct 2, 9:49 pm, Jo <[EMAIL PROTECTED]> wrote:
> HI,
>
> I am developing a chat application. Everytime a user clicks a button a
> thread needs to handle it as text message needs to be sent over
> network. so, I am creating a new thread each time when the user clicks
> on button.  I wish only 1 thread handles all the messages to be sent.
> But, resume/suspend/stop are all deprecated.
>
> is there a way to do it.
>
> currently, I am doing it like the following.
>
> <code>
> View.OnClickListener showChat = new View.OnClickListener() {
>                         @Override
>                         public void onClick(View v) {
>
>                                 t_send = new Thread() {
>                                         public void run() {
>                                                 recv = false;
>                                                 m_mychat = doExpensiveSend();
>
>                                                 
> mHandler2.post(mUpdateResults2);
>                                         }
>                                 };
>                                 t_send.start();
>
>                         }
>                 };
> </code>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
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