Thread safety between input and printing in screen