Index: src/Actions/ActionQueue.cpp
===================================================================
--- src/Actions/ActionQueue.cpp	(revision 9a4949ffbc4c1ce8a083f8878c8ff61e484e6e79)
+++ src/Actions/ActionQueue.cpp	(revision fff8fcbd58abd7059236c3fbddafc1000d300ae9)
@@ -102,5 +102,5 @@
   newaction->prepare(state);
 #ifdef HAVE_ACTION_THREAD
-  mtx_queue.lock();
+  mtx_actionqueue.lock();
 #endif
   actionqueue.push_back( newaction );
@@ -129,5 +129,5 @@
 #else
   const bool new_run_thread_isIdle = (CurrentAction == actionqueue.size());
-  mtx_queue.unlock();
+  mtx_actionqueue.unlock();
   {
     boost::lock_guard<boost::mutex> lock(mtx_run_thread_isIdle);
@@ -135,4 +135,20 @@
   }
 #endif
+}
+
+bool ActionQueue::isActionQueueDone() const
+{
+#ifdef HAVE_ACTION_THREAD
+  boost::lock_guard<boost::mutex> lock(mtx_actionqueue);
+#endif
+  return (CurrentAction == actionqueue.size());
+}
+
+bool ActionQueue::isTempQueueDone() const
+{
+#ifdef HAVE_ACTION_THREAD
+  boost::lock_guard<boost::mutex> lock(mtx_tempqueue);
+#endif
+  return tempqueue.empty();
 }
 
@@ -144,11 +160,13 @@
   Action *newaction = _action->clone(state);
   newaction->prepare(state);
-  mtx_queue.lock();
-  tempqueue.push_back( newaction );
-  {
-    boost::lock_guard<boost::mutex> lock(mtx_run_thread_isIdle);
-    run_thread_isIdle = !((CurrentAction != actionqueue.size()) || !tempqueue.empty());
-  }
-  mtx_queue.unlock();
+  {
+    boost::lock_guard<boost::mutex> lock(mtx_tempqueue);
+    tempqueue.push_back( newaction );
+  }
+  {
+    bool new_run_thread_isIdle = getrun_thread_isIdle();
+    new_run_thread_isIdle &= isTempQueueDone();
+    setrun_thread_isIdle(new_run_thread_isIdle);
+  }
 #endif
 }
@@ -176,12 +194,9 @@
 //    LOG(1, "DEBUG: Start of ActionQueue's run() loop.");
     // call all currently present Actions
-    mtx_queue.lock();
     insertTempQueue();
-    bool status = (CurrentAction != actionqueue.size());
-    mtx_queue.unlock();
-    while ((status) && (!Interrupted)) {
+    while ((!Interrupted) && (!isActionQueueDone())) {
       //      boost::this_thread::disable_interruption di;
       // access actionqueue, hence using mutex
-      mtx_queue.lock();
+      mtx_actionqueue.lock();
       LOG(0, "Calling Action " << actionqueue[CurrentAction]->getName() << " ... ");
       try {
@@ -210,6 +225,8 @@
       // we must have an extra vector for this, as we cannot change actionqueue
       // while an action instance is "in-use"
+      mtx_actionqueue.unlock();
+
       insertTempQueue();
-      status = (CurrentAction != actionqueue.size());
+
       // set last action
       if (lastActionOk) {
@@ -217,16 +234,10 @@
         NOTIFY(ActionQueued);
         _lastchangedaction = lastaction;
-        // unlock before we delve into Observer functions ...
-        mtx_queue.unlock();
-      } else {
-        mtx_queue.unlock();
       }
     }
-    mtx_queue.lock();
-    const bool new_run_thread_isIdle = !((CurrentAction != actionqueue.size()) || !tempqueue.empty());
-    mtx_queue.unlock();
     {
-      boost::lock_guard<boost::mutex> lock(mtx_run_thread_isIdle);
-      run_thread_isIdle = new_run_thread_isIdle;
+      bool new_run_thread_isIdle = isActionQueueDone();
+      new_run_thread_isIdle &= isTempQueueDone();
+      setrun_thread_isIdle(new_run_thread_isIdle);
     }
     cond_idle.notify_one();
@@ -242,5 +253,11 @@
 void ActionQueue::insertTempQueue()
 {
+#ifdef HAVE_ACTION_THREAD
+  boost::lock_guard<boost::mutex> lock(mtx_tempqueue);
+#endif
   if (!tempqueue.empty()) {
+#ifdef HAVE_ACTION_THREAD
+    boost::lock_guard<boost::mutex> lock(mtx_actionqueue);
+#endif
     ActionQueue_t::iterator InsertionIter = actionqueue.begin();
     std::advance(InsertionIter, CurrentAction);
@@ -251,12 +268,28 @@
 
 #ifdef HAVE_ACTION_THREAD
+void ActionQueue::setrun_thread_isIdle(
+    const bool _run_thread_isIdle)
+{
+  boost::unique_lock<boost::mutex> lock(mtx_run_thread_isIdle);
+  run_thread_isIdle = _run_thread_isIdle;
+}
+
+bool ActionQueue::getrun_thread_isIdle() const
+{
+  boost::unique_lock<boost::mutex> lock(mtx_run_thread_isIdle);
+  return run_thread_isIdle;
+}
+#endif
+
+#ifdef HAVE_ACTION_THREAD
 void ActionQueue::wait()
 {
-  boost::unique_lock<boost::mutex> lock(mtx_run_thread_isIdle);
-  if (run_thread_running)
+  if (run_thread_running) {
+    boost::unique_lock<boost::mutex> lock(mtx_run_thread_isIdle);
     while(!run_thread_isIdle)
     {
         cond_idle.wait(lock);
     }
+  }
 }
 #endif
@@ -339,14 +372,24 @@
 {
   // free all actions contained in actionqueue
-  for (ActionQueue_t::iterator iter = actionqueue.begin();
-      !actionqueue.empty(); iter = actionqueue.begin()) {
-    delete *iter;
-    actionqueue.erase(iter);
+  {
+#ifdef HAVE_ACTION_THREAD
+    boost::lock_guard<boost::mutex> lock(mtx_actionqueue);
+#endif
+    for (ActionQueue_t::iterator iter = actionqueue.begin();
+        !actionqueue.empty(); iter = actionqueue.begin()) {
+      delete *iter;
+      actionqueue.erase(iter);
+    }
   }
   // free all actions contained in tempqueue
-  for (ActionQueue_t::iterator iter = tempqueue.begin();
-      !tempqueue.empty(); iter = tempqueue.begin()) {
-    delete *iter;
-    tempqueue.erase(iter);
+  {
+#ifdef HAVE_ACTION_THREAD
+    boost::lock_guard<boost::mutex> lock(mtx_tempqueue);
+#endif
+    for (ActionQueue_t::iterator iter = tempqueue.begin();
+        !tempqueue.empty(); iter = tempqueue.begin()) {
+      delete *iter;
+      tempqueue.erase(iter);
+    }
   }
 #ifdef HAVE_ACTION_THREAD
