Exercise 1

  • Thanks to the principles exposed during the lectures, transform the server code of TP 1 into a multi-threaded server, with one thread for one client.
  • Apart from transferring the code concerning requests into the thread class, there is a problem with the Map that contains the distances of all clients.
  • In a multi-threaded version of the server, this Map can be accessed by several threads concurrently. Thus, all operations on the Map must be protected by a mutex.
  • This implies to put the Map within an object that is shared between threads (as the Box class used in course's examples).