Reputation: 5183
I have 2 classes ChatServer and ChatServerThread
public class ChatServer implements Runnable
{
private ServerSocket server = null;
private Thread thread = null;
private ChatServerThread client = null;
}
and
public class ChatServerThread extends Thread
{
private ChatServer server = null;
private Socket socket = null;
private int ID = -1;
private DataInputStream streamIn = null;
private DataOutputStream streamOut = null;
}
How would these compile? If I want to write a build script which class would you compile first?
Upvotes: 2
Views: 1369
Reputation: 47729
Conceptually, the compiler makes two passes over each Java source file, the first pass to extract the external definitions (equivalent to an "include file") that are needed by other classes, the second pass to actually compile things and create the .class file.
Upvotes: 2
Reputation: 310936
It doesn't matter. The compiler will compile both co-dependent classes either way.
But in fact your ChatServer
should not have a ChatServerThread
member at all, unless you're planning on only having one client in the chat.
Upvotes: 0