Printing name and getting input with multi threading

Question:
How do I print a name then get input while multi threading?
Repl link:
https://replit.com/@-jpg/freetext-MT-test

Example, from -jpg’s pov:

-jpg: From jpg
-jpg: 
loge95: from loge95
blank space
-jpg: -jpg: 
-jpg: blank space

from loge95’s pov:

-jpg: From jpg
from loge95
loge95: loge95: loge95: 
-jpg: blank space

you can see it is very desynced while printing name and then getting input

Ah! quick mention, they were on different versions of freetext although that is not the culprit

If you are multi threading there is no way to guarantee when a messages is sent, there is locking but idk how/if it supports it.

Also, just a few questions about the project:

  • is there any reason you are using the replit db? This is not really what is is meant to be used for and sockets would probably be more fitting.
  • Does the project work as normal if you remove the global keyword?
  1. its for fun, its not a serious thing at all. (and from experience, sockets are kinda buggy)

  2. no