synchronization using threads instead of event machine