Closed jmdejong closed 6 years ago
This has been solved in dcf01c8867288482a3173090ba08a7f331484e83: Two deamon threads now get input: one from socket, the other from keyboard. They pass it into a thread-safe queue withouth touching any other shared data. The main tread just reads messages from the queue in order.
The client uses 2 threads: the main thread for user input and another for receiving messages from the server and updating the display accordingly.
These threads don't have much shared data, but may get more in the future.
There is no thread safety between these threads.
The easiest solution is probably to put a lock on the client and have both of these theads require the lock for their updates (there's no real concurrency anyways).
An alternative solution is to try to drop threads in the first place and use something like
select
.