clear and add thread-safe print