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

Cheap web hosting provider

28
Oct

Black Art of Java Game Programming by Joel

while( true ) { try{ sleep(30000); } catch (Exception e); cleanHouse(); } } We re almost done! Only one more class to write. Remember, though, that you cannot compile sClientGroup yet, because it imports sClientThread, which hasn t been written yet! To get around this obstacle, let s write sClientThread. Creating the sClientThread Class The sClientThread object, and the previous one, sClientGroup, both need to call each other. If we wrote them both ahead of time and tried to compile them, the Java compiler would object. Why? Because when sClientThread imports sClientGroup, sClientGroup is not yet compiled, so the compiler tries to compile it. When sClientGroup tries to import sClientThread, it finds that it is not yet compiled as well, and tries to compile sClientThread. You probably noticed a most unfavorable pattern developing here. Therefore, we need to write an intermediate sClientThread file that only implements enough functionality to allow it and sClientGroup to be compiled. Here is a watered-down sClientThread with only the methods that are called by sClientGroup. We will talk more about these methods later, but for now it s important to get something written and compiled. Here it is: import java.net.*; import java.lang.*; import java.io.*; import java.util.*; import sClientGroup; public class sClientThread extends Thread { Object parent; Socket theSock; DataInputStream dis; PrintStream ps; String alias; sClientThread(Socket s, Object p) { theSock = s; parent = p; } public boolean message(String str) { try { ps.println(str); } catch (Exception e) { return false; } return true; }
Note: If you are looking for cheap and quality provider to host and run your java application check Astra java 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).