Forums Register Login

SurfaceHolder.Callback surfaceDestroyed()

+Pie Number of slices to send: Send
Hi Ed,

I noticed that the behavior of the example in the book was different from the Lunar Lander example.

In the book, in Chapter 10 (p 187) -



In Lunar Lander example, the call is made inside a loop catching the InterruptedException -


Looks like the first version might cause a problem if the thread is interrupted.
Will that be a problem in practice?

Cheers,
Sonny
+Pie Number of slices to send: Send
I asked a friend who knows more about Java joins and interrupts than I do and he said you're right. The second code snippet is more correct because if the current thread is interrupted while blocked in the join(), the first code will not actually join; it will continue on before the thread it has waiting for has finished. It needs to be in a loop as well. The flag retry gets reset if the join() returns successfully.

I've never encountered this in practice but it doesn't hurt to code defensively.

(It doesn't hurt to have smart friends down the hall either)
+Pie Number of slices to send: Send
Thanks, Ed. Good to know for sure.

Ed Burnette wrote:
(It doesn't hurt to have smart friends down the hall either)



Absolutely! And I am guessing that they are thinking the same thing
I hired a bunch of ninjas. The fridge is empty, but I can't find them to tell them the mission.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 5058 times.
Similar Threads
Please explain this code
setDaemon method
Question from k&B's masterexam about yield()???????
Stopping multi-thread
notify
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:44:04.