clientListenerService.start();
// after this line, you know that in background clients are being accepted,
// so you can enter the game loop/do other stuff as you wish
public void run()
{
// entry point for client connections
ServerSocket serverSocket = new ServerSocket(TCP_PORT);
while (!Thread.currentThread().isInterrupted())
{
(new ClientHandler(serverSocket.accept())).start();
}
}
synchronized(room/area) { <all your commands> }
while(1) {
parse_socket_commands()
run_mob_AI()
try_sync_database()
etc…
wait_for_next_timer_tick()
}
synchronize( someLock ) {
ch.startCasting( sp );
}
Thread.sleep(1000);
synchronize( someLock ) {
ch.castSpell( sp );
}