diff --git a/lib/spark/worker/master.rb b/lib/spark/worker/master.rb
index <HASH>..<HASH> 100755
--- a/lib/spark/worker/master.rb
+++ b/lib/spark/worker/master.rb
@@ -129,7 +129,8 @@ module Master
       ::Thread.abort_on_exception = true
 
       # For synchronous access to socket IO
-      $mutex = Mutex.new
+      $mutex_for_command  = Mutex.new
+      $mutex_for_iterator = Mutex.new
 
       super
     end
diff --git a/lib/spark/worker/worker.rb b/lib/spark/worker/worker.rb
index <HASH>..<HASH> 100644
--- a/lib/spark/worker/worker.rb
+++ b/lib/spark/worker/worker.rb
@@ -134,6 +134,10 @@ module Worker
 
     private
 
+      def load_command
+        $mutex_for_command.synchronize { super }
+      end
+
       # Threads changing for reading is very slow
       # Faster way is do it one by one
       def load_iterator
@@ -144,7 +148,7 @@ module Worker
           client_socket.wait_readable
         end
 
-        $mutex.synchronize { super }
+        $mutex_for_iterator.synchronize { super }
       end
 
   end
fix: thread worker for mri