Sign in to follow this  
YyYo

how to implement non I/O blocking

Recommended Posts

YyYo    137

Hi...

 

I newbie to the forum and to multiplayer game.

I started to implement a simple multiplayer game, using Java, and I have a question.

When 2 clients login to server, a new game is establish for them.

each player, in his turn, make a move and inform the server(which authenticate and send to opponent). 

 

when one player is playing, the other is waiting for the server to inform him that now its his turn(server send 'TURN' message)

The problem is that the player is waiting for the server by readLine() method which block the main thread.

I am planning to implement a Chat so the players could communicate each other, and if the main thread is block I wont be able to do so.

 

Should I need to implement 2 thread for each player: one for reading and one for writing, so the application wont block?

 

Any advice will appreciated.

 

Thx.

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this