thread synchronization problem solved