Is a program that only has one explicit thread running multithreaded? The reason I ask is that in the book Java after hours there are two programs that are similar and are called multithreaded. In one the thread controls a set amount of fish and moves them around the screen, but the Fish class does not implement runnable or extend thread. Is this really multi-threaded and why?
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Aquarium implements Runnable (instead of extending Thread) and starts a new Thread near the end of its constructor. There will be other housekeeping threads, like the GUI event processing thread and the garbage collector, so yes, this code is multithreaded. [ June 13, 2006: Message edited by: Joe Ess ]
Every Java program has several threads. Something has to run the garbage collector. Saying something is "multithreaded" implies that the programmer has utilized threads to make the program run smoother, do multiple tasks simultaneously or improve performance.
Joined: Jan 03, 2006
I have always thought of multi-threaded to mean that the program explicity uses multiple threads, not counting the ones in the background that the programmer has little to no control of, and this program was labeled multi-threaded seemed a bit confusing from my understanding of the term.
I was also confused a tad, because the fish were labeled as seperate threads(not by the book or its author), and that does not seem like the case here.
Anyway thanks a lot. I am having a blast modifying the code, I have added a pop up to control the amount of fish, added 15 fish .gif's that get loaded randomly, threw in a dolphin, shark, crab if the user wants them. Next up is the ability to choose different backgrounds, fish, allow the shark to feast on the fish, and maybe throw in a fisherman. Good fun and terrific book.