in reply to Re^3: Semaphores failing to prevent race condition
in thread Semaphores failing to prevent race condition

I've been trying to figure out how I could do this, and while I'm not going to come right out and way that it can't be done in this way, it's going to be non-trivial. The inter-thread interface is going to be extremely complex, because while the listener and status threads simply print complete messages to the screen, the talker thread outputs one character at a time and does direct character positioning.

However, what I can possibly do is have the talker thread be the thread that does all the screen I/O for the other threads, in between listening for keyboard events. This would eliminate the need to figure out how to send its readline-like events as messages, and would satisfy the goal of having all I/O occur in a single thread.

  • Comment on Re^4: Semaphores failing to prevent race condition

Replies are listed 'Best First'.
Re^5: Semaphores failing to prevent race condition
by roboticus (Chancellor) on Mar 14, 2011 at 19:31 UTC

    Llew_Llaw_Gyffes:

    Yeah, it's often very difficult to change I/O in an application after it's done. I like your idea of using your talker thread to handle the I/O for other threads, especially because it's the one that outputs character-by-character, rather than complete messages.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.