This will put your app's message looper to sleep for 10 seconds, which
is probably not what you want. As an alternative, you can send
yourself a delayed message, or you can have your animation thread read
the system time when it starts up and exit after the 10 seconds has
expired.

On Jan 17, 2:55 am, steve_macleod <[email protected]> wrote:
> Hi,
> I am writing an application to get a grip of basic sprite animation. I
> have a surfaceCreated method which looks like this:
>
> public void surfaceCreated(SurfaceHolder holder) {
>                 mPacManThread.setRunning(true);
>                 mPacManThread.start();
>                 //this thread will wait for 10 seconds, and then kill the
> mPacManThread thread
>
>                 try {
>                         Thread.sleep(10000);
>                         mPacManThread.setRunning(false);
>                         Log.d("THREAD STOPPED","The animation thread has been 
> stopped, as
> 10 seconds has elapsed.");
>
>                 } catch (InterruptedException e) {
>                         // TODO Auto-generated catch block
>                         e.printStackTrace();
>                 }
>
>         }
>
> The intention is to start the thread which manages the user input and
> animation, and make the main thread (that is the thread that started
> the view) sleep for 10 seconds, before stopping the animation loop.
>
> My understanding is that the Thread.sleep(10000) will sleep the thread
> from which the request originated (ie the main thread) for 10 seconds.
>
> However, it looks like the Thread.sleep() is actually working on the
> animation (mPacManThread) instead. Am I missing something fundamental
> here?
>
> Thanks,
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to