I've finished adding Thead-per-client in my server, no errors, it's fine.
But when I run the server, I get this exception:
Code:
Exception in thread "Thread-0" java.lang.NullPointerException
at com.iClarity.io.IOThread.run(IOThread.java:17)
at java.lang.Thread.run(Unknown Source)
Line 17 in my IOThread class:
Code:
GameEngine.playerHandler.processIOClients();
The 'processIOClients' method in my PlayerHandler class:
Code:
public void processIOClients() {
synchronized(add) {
while(true) {
IOClient toAdd = add.poll();
if(toAdd == null) break;
ioClients.add(toAdd);
}
}
synchronized(ioClients) {
for(IOClient ioc : ioClients) {
try {
if(ioc.process()) {
removeNoClose.add(ioc);
}
} catch (Exception e) {
System.err.println(e.getMessage());
remove.add(ioc);
}
}
}
synchronized(remove) {
while(true) {
IOClient toRemove = remove.poll();
if(toRemove == null) break;
toRemove.destruct(true);
ioClients.remove(toRemove);
}
}
synchronized(removeNoClose) {
while(true) {
IOClient toRemove = removeNoClose.poll();
if(toRemove == null) break;
toRemove.destruct(false);
ioClients.remove(toRemove);
}
}
}
Anyone know the problem?