That makes sense.

Like I said, you should lock the object that the thread is
accessing..., and again, please instrument your program (by adding
logging code) to ensure that this is really what's happening...!

There's not a correspondence between threads started in one activity
and the activity: the activity's UI code will run on the main thread
no matter what, yyour thread will just be scheduled around that.

Kris


On Fri, Apr 26, 2013 at 10:51 PM, bob <[email protected]> wrote:
> Well, I figured out that it happens if I do this:
>
> Hit the back button.
> Hold the home button down.
> Select the Activity from the list.
>
>
> I guess the physics thread just doesn't get killed?  Can I assume it is
> still running?  I guess it probably makes more sense to start it in onResume
> and kill it in onPause?
>
> Thanks.
>
>
>
> On Friday, April 26, 2013 8:30:10 PM UTC-5, Kristopher Micinski wrote:
>>
>> Did you instrument your code to verify that this is indeed the case?
>> This would definitely be the first thing to do: since it would verify
>> whether what you are saying is happening is correct.  I would
>> generally say that I rarely see duplicated onCreates unless your
>> activity is clearly destroyed: but I have noticed cases of it before.
>> (However, fixing the orientation does help..)
>>
>> The fact there would be two "physics threads" running seems strange to
>> me, since I usually segment things as much as possible.
>>
>> (By the way, you should probably mediate access to the objects you're
>> updating by acquiring a lock for them: that's the "typical solution"
>> to the kind of problem you present here.)
>>
>> Kris
>>
>>
>> On Fri, Apr 26, 2013 at 9:13 PM, bob <[email protected]> wrote:
>> > Okay, so I'm trying to track down a bug in a game I wrote.
>> >
>> > Basically, once in awhile the physics of the game will run about twice
>> > as
>> > fast as it should.  This suggests to me that there are two physics
>> > threads
>> > running simultaneously.
>> >
>> > The code I wrote creates a physics thread in the constructor of my
>> > GLSurfaceView.Renderer subclass.  This subclass gets created in the
>> > onCreate
>> > method.
>> >
>> > So, I'm guessing onCreate must be getting called again without the first
>> > physics thread dying.  I restricted the orientation of the app to
>> > landscape,
>> > so I don't think it could be orientation-related.  Any ideas how
>> > onCreate
>> > would be called again without the first physics thread dying?
>> >
>> > Thanks.
>> >
>> > --
>> > --
>> > 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
>> > ---
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Android Developers" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to [email protected].
>> > For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> >
>
> --
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to