Do you understand that in code like this:
public void close(boolean closed) throws IOException {
if(star == true) {
h.close();
OSW.close();
run = false;
closed = true;
} else {
closed = false;
}
}
the assignment to ‘closed’ does absolutely nothing? ‘closed’ is passed BY VALUE, like everything in Java. All that code does is change the value of the LOCAL variable ‘closed’, the actual variable that you passed when you called the method remains unaffected.
In particular, this block of your latest code
boolean exit = false;
try {
s.close(exit);
this.yield();
} catch (IOException ex) {
ex.printStackTrace();
}
while(exit == false) {
System.out.println("will not close");
System.out.println("wil not close");
System.out.println("clossing");
try {
s.close(exit);
} catch (IOException ex) {
ex.printStackTrace();
}
System.out.println("tryed");
}
if(exit == true) {
System.out.println("closed");
}
has an infinite while-loop because ‘exit’ = false and it can never change. Since it is a local variable it can’t be touched outside that thread and nothing in that thread changes it after it has been initialized.
I don’t intend to sound mean, but your code shows a basic lack of understanding of the Java language in general. You should probably work on that a bit before you tackle writing a game. Game programming is usually not beginner-level coding, unless you start with some very simple games, like Tic-Tac-Toe.
Have you gone through the Java tutorials a java.sun.com? They are a good place to get familiar with the language.
You should probably post in Newless Clubies unless you are really having a problem with networking as opposed to just general coding issues.