Web Hosting Tomcat, Java, JSP, Servlets, J2EE, PHP, MySQL

Cheap web hosting provider

30
Sep

Black Art of Java Game Programming by Joel

method name with the class name and a dot. The run() method has its name for a particular reason. Take a look at the first line of Broadway: public class Broadway extends Applet implements Runnable { … Not only does Broadway extend Applet (meaning that it s a subclass of Applet), but it implements Runnable as well. Runnable is an interface, which means that it specifies a set of methods that must be implemented by Broadway. run() is an example of such a method. You ll learn more about interfaces in the next chapter; for now, remember that a class that implements an interface supplies the needed methods, whereas a class that inherits a method gets it for free! Now let s trace the execution of Broadway to see how it reaches the run() method. Tracing the Applet s Execution Path The execution path of Broadway is a bit complex. As you will recall, init() is called to initialize the applet, and then start() is called: public void start() { System.out.println(”>> start <<"); animation = new Thread(this); if (animation != null) { animation.start(); } } start() does two things: 1. It creates a new thread called animation. (You ll learn what the this keyword is, in the Using Objects section below.) 2. It tells the animation thread to start executing the code in run(), by calling animation.start(). In effect, another thread of execution is created to execute the animation loop in run(). Figure 2-3 shows how the execution path of Broadway splits into two separate paths once the new thread is started.
Note: If you are looking for inexpensive but high quality provider to host and run your jsp application check Astra jsp hosting services

Comments are closed.

Home | About Us | Compare Plans | Standard Hosting | Business Hosting | Java Tomcat Hosting | Support | FAQ | Order Now!

Powered by Omnicus java hosting services. All rights reserved.
Entries (RSS) and Comments (RSS).