Add locking in the two threads in order the snake to be printed correctly.