need to fix sync problem in ThreadsManagemenent.cs