Thread synchronization fixed, it works!