Hi, I'm programming a game in j2me in the client side, that connects to a server written in java. This game is going to have a chat feature, but as a secondary feature.
For every midlet that connects to the server, a server-game thread is spawned. These threads talk between them, so that they can synchronize and write in turns to a series of config files in the server. Now, if a chat message is written in one of the midlets, it's passed along to a client-side thread that manages the socket communication and gets sent to the server. In the server, all other players of the same game are notified, and the chat messag is relayed to all of them. So every server thread (but the one of the user that sent the message originally) send to their correspondent client thread the message.
Here comes my question. How can I signal each midlet so that it knows there's a new incoming message?
I thought about making a thread that polls the client-side communication thread to see if there's any new message. But then, how can I know from the midlet, without interrupting it halfway? Ideally, I'd want to read directly a string that's in the client-side communication thread, but that string could be being written, so I need a thread to access it and synchronize to it.
Can any of you guys give a hand? I don't really know how to proceed, and it seems this should be pretty straightforward...
thanks in advance