Missile Command / Multithreading issues!

Hey everyone. I started coding my first game in java recently, which is an applet implementation of missile command. (before this, I'd only coded a few VERY simple games in VB and VC++)

Anyways, It started out great, but I started getting problems like flickering, and even all out crashes(in appletviewer) as soon as I added the capability of firing a "missile" during a key press event.

The way I've designed it, every object on the screen is being drawn by it's own class. These classes are derivation from classes called "missile" and "alien", both of which "extends Thread".

So everything on the screen has it's own thread updating it's position and drawing it to the buffer, which means when there's alot of aliens and alot of missiles recently fired, you have a hell of alot of threads!

Was this, perhaps a bad design idea? :)

If so, does anyone know a better approach to take?

anyways, here's where I'm at so far:

http://www.geocities.com/hamburglarshero/missile/missile.html

[1041 byte] By [carmichaelbaby] at [2007-9-27 16:46:20]
# 1

Yeah, it's because of the many threads you're creating. There's a limit of how many threads a computer can handle though it varies between computers. Having a thread for every missle won't work, instead you could make one thread to control missile objects. To solve flickering you could override update() and double buffer, there's plenty of information on the forums if you haven't done something like that. Search if you're interested. Most of the time, you want to keep threads to a minimum without hurting the design .

Ceranith at 2007-7-6 1:04:20 > top of Java-index,Other Topics,Java Game Development...
# 2
Thanks for the info.I read a tutorial on flicker free animation usingdouble buffering and overriding the update method, and thats exactlywhat I did. I'm going to see if I can make it work with maybe two threads.
carmichaelbaby at 2007-7-6 1:04:20 > top of Java-index,Other Topics,Java Game Development...