[quote]Ok, backing to the real problem.
So, any ideia on how to make timeleft measure, for example, to the next round? A single round take 6 min, and from one round to another, it can take for least, 1 min. My question is: can I use a separated Thread, inside my applet, to do something like this:
[/quote]
This is a great situation for TimerTask and Timer. Have a look in java.util.* for those classes - they’re pretty self-explanatory, and part of the standard API.
You should be able to get them up and running v. quickly and easily. If not, post here again or msg me and I’ll give you some sample code (but you probably won’t need it :)).
Yeah, well, there’re a lot of misinformed opinions floating about the internet, aren’t there? But seriously, without context it’s hard to know exactly what the reason was for that statement; it could well make perfect sense in the original context, but that context might have been lost when it got re-told several times to different people.
The need to “only have one thread” in a game comes mainly from when you are doing a lot of processing, or have a “real-time” game where you need to animate lots of things, have complex AI running in parallel, etc etc. Typically, if what you are doing is not action based, it’s not worth the effort (it often won’t bring you any benefits, but will cut down your available design decisions).
For applets specifically, I would always advise newbie java programmers to single-thread for a while mainly because they forget to obey the Applet contract - i.e. the stop() start() load() unload() etc methods - and end up leaving threads running in the web browser that they don’t know about and CANNOT terminate. A long time ago I wrote a fast 3D animated mandelbrot applet, and made this mistake. Every time you re-visited the page to show it to someone, it got slower :). Oh, how amusing that sounds now! But back then, it was very difficult to work out.
As soon as you feel confident you know your applet is stopping all it’s threads at the right point, there is absolutely no special reason not to use multiple threads. Use twenty of them - your OS probably won’t even notice (Ahem. Assuming it’s less than 8 years old…).
Hey, even Sun’s official tutorials include examples of running multiple Thread’s from within an Applet, so I really wouldn’t worry if I were you!