Thanks for replyin...

I havn't declared the variable as volatile... I'll do that.. .

Also.. I'm worried whether the variable is returning the current state
of the Activity rather than the thread.

Thanks,
Immanuel


On Feb 22, 6:06 pm, David Turner <[email protected]> wrote:
> Did you declare your variable as volatile ? this is needed for stuff that
> can be accessed by several threads at the same time.(or you could use a
> synchronized statement which is slower but is safer in the general case, but
> probably equivalent if your variable is of primitive type *and* you're not
> running on multi-core device).
>
> On Sun, Feb 22, 2009 at 10:39 AM, Immy <[email protected]> wrote:
>
> > Hi,
>
> > I am using this method to identify if a thread is running at any point
> > of time, irrespective of whether the enclosing activity is running or
> > not.
>
> > Is this the right way?
>
> > Please reply.
>
> > Java:
>
> > Thread t = new Thread(new Runnable(){
>
> >              public void run()
> >              {
> >                Looper.prepare();
>
> >                        //DO SOME WORK
>
> >                  Looper.loop();
> >              }
> >               });
> >          isRunning = true;
> >          t.start();
>
> >         this.finish();
> >     }
>
> >     public void onStop()
> >     {
> >          super.onStop();
> >          isRunning=false;
> >     }
>
> >     public boolean CheckRunningSync()
> >     {
> >          boolean returner = true;
>
> >          if(isRunning == false)
> >               returner = false;
> >          if(isRunning == true)
> >               returner = true;
>
> >          return returner;
> >     }
>
> > isRunning is a boolean local variable.
>
> > Thanks,
> > Immanuel
>
>
--~--~---------~--~----~------------~-------~--~----~
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