Index: code/branches/console/src/core/Executor.h
===================================================================
--- code/branches/console/src/core/Executor.h	(revision 1230)
+++ code/branches/console/src/core/Executor.h	(revision 1247)
@@ -35,4 +35,5 @@
 #include "util/SubString.h"
 #include "util/String.h"
+#include "util/Math.h"
 #include "Functor.h"
 #include "Debug.h"
@@ -100,5 +101,5 @@
             COUT(5) << tokens[i]; \
         } \
-        COUT(5) << ") and " << (paramCount - tokens.size()) << " default values ("; \
+        COUT(5) << ") and " << max((int)paramCount - (int)tokens.size(), 0) << " default values ("; \
         for (unsigned int i = tokens.size(); i < paramCount; i++) \
         { \
Index: code/branches/console/src/core/TclBind.cc
===================================================================
--- code/branches/console/src/core/TclBind.cc	(revision 1230)
+++ code/branches/console/src/core/TclBind.cc	(revision 1247)
@@ -137,5 +137,5 @@
         catch (std::exception const &e)
         {
-            COUT(1) << "Error while executing tcl: " << e.what() << std::endl;
+            COUT(1) << "Error while executing Tcl: " << e.what() << std::endl;
         }
 
@@ -156,5 +156,5 @@
         catch (std::exception const &e)
         {
-            COUT(1) << "Error while executing tcl: " << e.what() << std::endl;
+            COUT(1) << "Error while executing Tcl: " << e.what() << std::endl;
         }
 
Index: code/branches/console/src/core/TclThreadManager.cc
===================================================================
--- code/branches/console/src/core/TclThreadManager.cc	(revision 1230)
+++ code/branches/console/src/core/TclThreadManager.cc	(revision 1247)
@@ -53,4 +53,6 @@
     ConsoleCommand(TclThreadManager, execute,   AccessLevel::None, false);
     ConsoleCommand(TclThreadManager, query,     AccessLevel::None, false);
+    ConsoleCommand(TclThreadManager, status,    AccessLevel::None, false);
+    ConsoleCommand(TclThreadManager, dump,      AccessLevel::None, false);
 
     TclThreadManager* instance = &TclThreadManager::getInstance();
@@ -62,4 +64,6 @@
         this->IDcount_ = 0;
         this->isReady_ = false;
+        this->isQuerying_ = false;
+        this->queryID_ = 0;
     }
 
@@ -103,7 +107,92 @@
     }
 
+    void TclThreadManager::status()
+    {
+        COUT(0) << "Thread ID" << '\t' << "Queue size" << '\t' << "State" << std::endl;
+
+        std::string output = "Orxonox";
+        output += "\t\t";
+        {
+            // mutex orxqueue
+            boost::mutex::scoped_lock lock(TclThreadManager::getInstance().orxonoxQueueMutex_);
+            output += getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().orxonoxQueue_.size());
+        }
+        output += "\t\t";
+        {
+            // mutex orxstate
+            boost::mutex::scoped_lock lock(TclThreadManager::getInstance().orxonoxStateMutex_);
+            if (TclThreadManager::getInstance().isReady_)
+                output += "ready";
+            else
+                output += "busy";
+        }
+        COUT(0) << output << std::endl;
+
+        // mutex threads
+        boost::mutex::scoped_lock lock(TclThreadManager::getInstance().threadsMutex_);
+        for (std::map<unsigned int, TclThread*>::const_iterator it = TclThreadManager::getInstance().threads_.begin(); it != TclThreadManager::getInstance().threads_.end(); ++it)
+        {
+            std::string output = getConvertedValue<unsigned int, std::string>((*it).first);
+            output += "\t\t";
+            {
+                boost::mutex::scoped_lock lock(TclThreadManager::getInstance().threadQueuesMutex_);
+                std::map<unsigned int, std::pair<std::queue<std::string>, boost::condition*> >::const_iterator it2 = TclThreadManager::getInstance().threadQueues_.find((*it).first);
+                if (it2 != TclThreadManager::getInstance().threadQueues_.end())
+                    output += getConvertedValue<unsigned int, std::string>((*it2).second.first.size());
+                else
+                    output += "-";
+            }
+            output += "\t\t";
+            if (TclThreadManager::getInstance().getState((*it).second) == TclThread::Ready)
+                output += "ready";
+            else
+                output += "busy";
+
+            COUT(0) << output << std::endl;
+        }
+    }
+
+    void TclThreadManager::dump(unsigned int threadID)
+    {
+        if (threadID == 0)
+        {
+            // mutex orxqueue
+            boost::mutex::scoped_lock lock(TclThreadManager::getInstance().orxonoxQueueMutex_);
+
+            COUT(0) << "Queue dump of Orxonox:" << std::endl;
+            for (unsigned int index = 0; index < TclThreadManager::getInstance().orxonoxQueue_.size(); index++)
+            {
+                std::string command = TclThreadManager::getInstance().orxonoxQueue_.front();
+                COUT(0) << index << ": " << command << std::endl;
+                TclThreadManager::getInstance().orxonoxQueue_.pop();
+                TclThreadManager::getInstance().orxonoxQueue_.push(command);
+            }
+        }
+        else
+        {
+            // mutex threadqueues
+            boost::mutex::scoped_lock lock(TclThreadManager::getInstance().threadQueuesMutex_);
+
+            std::map<unsigned int, std::pair<std::queue<std::string>, boost::condition*> >::iterator it = TclThreadManager::getInstance().threadQueues_.find(threadID);
+            if (it != TclThreadManager::getInstance().threadQueues_.end())
+            {
+                COUT(0) << "Queue dump of Tcl-thread " << threadID << ":" << std::endl;
+                for (unsigned int index = 0; index < (*it).second.first.size(); index++)
+                {
+                    std::string command = (*it).second.first.front();
+                    COUT(0) << index << ": " << command << std::endl;
+                    (*it).second.first.pop();
+                    (*it).second.first.push(command);
+                }
+            }
+            else
+            {
+                COUT(1) << "Error: (" << __LINE__ << ") No Tcl-thread with ID " << threadID << "." << std::endl;
+            }
+        }
+    }
+
     void TclThreadManager::tcl_execute(Tcl::object const &args)
     {
-std::cout << "3_1\n";
 std::cout << "Tcl-thread_execute: args: " << args.get() << std::endl;
         std::string command = args.get();
@@ -115,11 +204,20 @@
     }
 
-    std::string TclThreadManager::tcl_orxonox(Tcl::object const &args)
-    {
-std::cout << "4_1\n";
-std::cout << "Tcl-thread_orxonox: args: " << args.get() << std::endl;
+    std::string TclThreadManager::tcl_query(int id, Tcl::object const &args)
+    {
+std::cout << "Tcl-thread_query: id: " << id << " args: " << args.get()  << std::endl;
+        {
+            // mutex query
+            boost::mutex::scoped_lock lock(TclThreadManager::getInstance().orxonoxQueryMutex_);
+            if (TclThreadManager::getInstance().isQuerying_ && (id == (int)TclThreadManager::getInstance().queryID_))
+            {
+                COUT(1) << "Error: Orxonox Tcl-interpreter can't be queried right now." << std::endl;
+                return "";
+            }
+        }
+
         std::string command = args.get();
 
-        if (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}')
+        while (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}')
             command = command.substr(1, command.size() - 2);
 
@@ -129,13 +227,26 @@
     Tcl::interpreter* TclThreadManager::createTclInterpreter(unsigned int threadID) const
     {
-        Tcl::interpreter* i = new Tcl::interpreter(TclBind::getInstance().getTclLibPath());
-
-        i->def("orxonox", TclThreadManager::tcl_orxonox, Tcl::variadic());
+        Tcl::interpreter* i = 0;
+        i = new Tcl::interpreter(TclBind::getInstance().getTclLibPath());
+
+        i->def("query", TclThreadManager::tcl_query, Tcl::variadic());
         i->def("execute", TclThreadManager::tcl_execute, Tcl::variadic());
 
         std::string id = getConvertedValue<unsigned int, std::string>(threadID);
-        i->eval("rename exit tclexit; proc exit {} { orxonox TclThreadManager destroy " + id + " }");
-        i->eval("set threadid " + id);
-        i->eval("redef_puts");
+        try
+        {
+            i->eval("rename exit tclexit; proc exit {} { orxonox TclThreadManager destroy " + id + " }");
+            i->eval("proc orxonox args { query " + id + " $args }");
+            i->eval("set threadid " + id);
+            i->eval("redef_puts");
+        }
+        catch (Tcl::tcl_error const &e)
+        {
+            COUT(1) << "Tcl error: " << e.what() << std::endl;
+        }
+        catch (std::exception const &e)
+        {
+            COUT(1) << "Error while creating Tcl-thread (" << id << "): " << e.what() << std::endl;
+        }
 
         return i;
@@ -145,8 +256,11 @@
     {
         this->IDcount_++;
-        Tcl::interpreter* i = this->createTclInterpreter(this->IDcount_);
-        boost::try_mutex* m = new boost::try_mutex;
-        boost::thread*    t = new boost::thread(boost::bind(&tclThreadLoop, i, m, this->IDcount_));
-        TclThread newthread = {i, t, m};
+        TclThread* newthread = new TclThread;
+        newthread->threadID_ = this->IDcount_;
+        newthread->interpreter_ = this->createTclInterpreter(this->IDcount_);
+        newthread->evalMutex_ = new boost::mutex;
+        newthread->stateMutex_ = new boost::mutex;
+        newthread->state_ = new TclThread::State(TclThread::Ready);
+        newthread->thread_ = new boost::thread(boost::bind(&tclThreadLoop, newthread));
         {
             // mutex threads
@@ -157,5 +271,5 @@
             // mutes threadqueues
             boost::mutex::scoped_lock lock(this->threadQueuesMutex_);
-            this->threadQueues_[this->IDcount_];
+            this->threadQueues_[this->IDcount_] = std::pair<std::queue<std::string>, boost::condition*>(std::queue<std::string>(), new boost::condition());
         }
         return true;
@@ -167,10 +281,16 @@
         boost::mutex::scoped_lock lock(this->threadsMutex_);
 
-        std::map<unsigned int, TclThread>::iterator it = this->threads_.find(threadID);
+        std::map<unsigned int, TclThread*>::iterator it = this->threads_.find(threadID);
         if (it != this->threads_.end())
         {
-            delete (*it).second.interpreter_;
-            delete (*it).second.thread_;
-            delete (*it).second.mutex_;
+            this->setState((*it).second, TclThread::Finished);
+            (*it).second->thread_->timed_join(boost::posix_time::time_duration(0, 0, 0, 10));
+
+            delete (*it).second->interpreter_;
+            delete (*it).second->thread_;
+            delete (*it).second->evalMutex_;
+            delete (*it).second->stateMutex_;
+            delete (*it).second->state_;
+            delete (*it).second;
 
             this->threads_.erase(it);
@@ -178,5 +298,14 @@
                 // mutex threadqueues
                 boost::mutex::scoped_lock lock(this->threadQueuesMutex_);
-                this->threadQueues_.erase(threadID);
+                std::map<unsigned int, std::pair<std::queue<std::string>, boost::condition*> >::iterator it = this->threadQueues_.find(threadID);
+                if (it != this->threadQueues_.end())
+                {
+                    delete (*it).second.second;
+                    this->threadQueues_.erase(threadID);
+                }
+                else
+                {
+                    return false;
+                }
             }
             return true;
@@ -184,7 +313,22 @@
         else
         {
-            COUT(1) << "Error: No Tcl-thread with ID " << threadID << "." << std::endl;
+            COUT(1) << "Error: (" << __LINE__ << ") No Tcl-thread with ID " << threadID << "." << std::endl;
             return false;
         }
+    }
+
+    void TclThreadManager::setState(TclThread* tclThread, TclThread::State state)
+    {
+        // mutex state
+        boost::mutex::scoped_lock lock(*tclThread->stateMutex_);
+        *tclThread->state_ = state;
+    }
+
+    TclThread::State TclThreadManager::getState(TclThread* tclThread)
+    {
+        // mutex state
+        boost::mutex::scoped_lock lock(*tclThread->stateMutex_);
+        TclThread::State state = *tclThread->state_;
+        return state;
     }
 
@@ -194,5 +338,5 @@
         boost::mutex::scoped_lock lock(this->orxonoxQueueMutex_);
 
-        while (this->orxonoxQueue_.size() == TCLTHREAD_MAX_QUEUE_LENGTH)
+        while (this->orxonoxQueue_.size() >= TCLTHREAD_MAX_QUEUE_LENGTH)
             this->orxonoxQueueCondition_.wait(lock);
 
@@ -226,12 +370,15 @@
         boost::mutex::scoped_lock lock(this->threadQueuesMutex_);
 
-        std::map<unsigned int, std::queue<std::string> >::iterator it = this->threadQueues_.find(threadID);
+        std::map<unsigned int, std::pair<std::queue<std::string>, boost::condition*> >::iterator it = this->threadQueues_.find(threadID);
         if (it != this->threadQueues_.end())
         {
-            (*it).second.push(command);
+            while ((*it).second.first.size() >= TCLTHREAD_MAX_QUEUE_LENGTH)
+                (*it).second.second->wait(lock);
+
+            (*it).second.first.push(command);
         }
         else
         {
-            COUT(1) << "Error: No Tcl-thread with ID " << threadID << "." << std::endl;
+            COUT(1) << "Error: (" << __LINE__ << ") No Tcl-thread with ID " << threadID << "." << std::endl;
         }
     }
@@ -242,14 +389,14 @@
         boost::mutex::scoped_lock lock(this->threadQueuesMutex_);
 
-        std::map<unsigned int, std::queue<std::string> >::iterator it = this->threadQueues_.find(threadID);
+        std::map<unsigned int, std::pair<std::queue<std::string>, boost::condition*> >::iterator it = this->threadQueues_.find(threadID);
         if (it != this->threadQueues_.end())
         {
-            std::string command = (*it).second.front();
-            (*it).second.pop();
+            std::string command = (*it).second.first.front();
+            (*it).second.first.pop();
             return command;
         }
         else
         {
-            COUT(1) << "Error: No Tcl-thread with ID " << threadID << "." << std::endl;
+            COUT(1) << "Error: (" << __LINE__ << ") No Tcl-thread with ID " << threadID << "." << std::endl;
             return "";
         }
@@ -261,12 +408,12 @@
         boost::mutex::scoped_lock lock(this->threadQueuesMutex_);
 
-        std::map<unsigned int, std::queue<std::string> >::iterator it = this->threadQueues_.find(threadID);
+        std::map<unsigned int, std::pair<std::queue<std::string>, boost::condition*> >::const_iterator it = this->threadQueues_.find(threadID);
         if (it != this->threadQueues_.end())
         {
-            return (*it).second.empty();
+            return (*it).second.first.empty();
         }
         else
         {
-            COUT(1) << "Error: No Tcl-thread with ID " << threadID << "." << std::endl;
+            COUT(1) << "Error: (" << __LINE__ << ") No Tcl-thread with ID " << threadID << "." << std::endl;
             return true;
         }
@@ -275,5 +422,6 @@
     std::string TclThreadManager::eval(const std::string& command)
     {
-        boost::mutex::scoped_lock lock(this->orxonoxEvalMutex_);
+        // mutex orxstate
+        boost::mutex::scoped_lock lock(this->orxonoxStateMutex_);
 
         while (!this->isReady_)
@@ -290,45 +438,59 @@
     std::string TclThreadManager::eval(unsigned int threadID, const std::string& command)
     {
-        // mutex threads
-        boost::mutex::scoped_lock lock(this->threadsMutex_);
-
-        std::map<unsigned int, TclThread>::iterator it = this->threads_.find(threadID);
-        if (it != this->threads_.end())
-        {
-            boost::try_mutex::scoped_try_lock lock(*(*it).second.mutex_, boost::defer_lock_t());
-            bool threadIsReady = false;
-            try
-            {
-                threadIsReady = lock.try_lock();
-            }
-            catch(boost::lock_error& e){ std::cout << "lockerror thread" << std::endl; }
-
-            if (threadIsReady)
-            {
-                try
-                {
+        {
+            // mutex query
+            boost::mutex::scoped_lock lock(this->orxonoxQueryMutex_);
+            this->isQuerying_ = true;
+            this->queryID_ = threadID;
+std::cout << "2_0\n";
+        }
+
+        {
+            // mutex threads
+            boost::mutex::scoped_lock lock(this->threadsMutex_);
+
+            std::map<unsigned int, TclThread*>::iterator it = this->threads_.find(threadID);
+            if (it != this->threads_.end())
+            {
 std::cout << "2_1\n";
-                    return (*it).second.interpreter_->eval(command);
-                }
-                catch (Tcl::tcl_error const &e)
+                if (this->getState((*it).second) == TclThread::Ready)
                 {
 std::cout << "2_2\n";
-                    COUT(1) << "Tcl error: " << e.what() << std::endl;
-                }
-                catch (std::exception const &e)
-                {
+                    // mutex threadeval
+                    boost::mutex::scoped_lock lock(*(*it).second->evalMutex_);
+                    try
+                    {
 std::cout << "2_3\n";
-                    COUT(1) << "Error while executing tcl: " << e.what() << std::endl;
+                        return (*it).second->interpreter_->eval(command);
+                    }
+                    catch (Tcl::tcl_error const &e)
+                    {
+                        COUT(1) << "Tcl error: " << e.what() << std::endl;
+                    }
+                    catch (std::exception const &e)
+                    {
+                        COUT(1) << "Error while executing Tcl: " << e.what() << std::endl;
+                    }
+    std::cout << "2_4\n";
+                }
+                else
+                {
+                    COUT(1) << "Error: Tcl-thread with ID " << threadID << " is not ready. Wait until it's finished or start a new thread." << std::endl;
                 }
             }
             else
             {
-                COUT(1) << "Error: Tcl-thread with ID " << threadID << " is not ready. Wait until it's finished or start a new thread." << std::endl;
-            }
-        }
-        else
-        {
-            COUT(1) << "Error: No Tcl-thread with ID " << threadID << "." << std::endl;
-        }
+                COUT(1) << "Error: (" << __LINE__ << ") No Tcl-thread with ID " << threadID << "." << std::endl;
+            }
+        }
+
+        {
+            // mutex query
+            boost::mutex::scoped_lock lock(this->orxonoxQueryMutex_);
+            this->isQuerying_ = false;
+            this->queryID_ = 0;
+std::cout << "2_5\n";
+        }
+
         return "";
     }
@@ -337,5 +499,6 @@
     {
         {
-            boost::mutex::scoped_lock lock(this->orxonoxEvalMutex_);
+            // mutex orxstate
+            boost::mutex::scoped_lock lock(this->orxonoxStateMutex_);
             this->isReady_ = true;
         }
@@ -345,5 +508,6 @@
 
         {
-            boost::mutex::scoped_lock lock(this->orxonoxEvalMutex_);
+            // mutex orxstate
+            boost::mutex::scoped_lock lock(this->orxonoxStateMutex_);
             this->isReady_ = false;
         }
@@ -359,52 +523,66 @@
     }
 
-    void tclThreadLoop(Tcl::interpreter* interpreter, boost::try_mutex* mutex, unsigned int threadID)
+    void tclThreadLoop(TclThread* tclThread)
     {
         while (true)
         {
-            {
-                boost::try_mutex::scoped_try_lock lock(*mutex, boost::defer_lock_t());
-                bool threadIsReady = false;
+            if (!TclThreadManager::getInstance().isEmpty(tclThread->threadID_))
+            {
+                std::cout << "a\n";
+                TclThreadManager::getInstance().setState(tclThread, TclThread::Busy);
+//                if (!TclThreadManager::getInstance().isEmpty(tclThread->threadID_))
+                {
+                    try
+                    {
+                        std::cout << "c\n";
+                        throw std::exception();
+                        std::cout << "d\n";
+                    }
+                    catch (...)
+                    {
+                        std::cout << "e\n";
+                    }
+                }
+                TclThreadManager::getInstance().setState(tclThread, TclThread::Ready);
+                std::cout << "f\n";
+
+//                boost::this_thread::yield();
+//                if (TclThreadManager::getInstance().getState(tclThread) == TclThread::Finished)
+//                    return;
+            }
+        }
+
+/*        while (true)
+        {
+            TclThreadManager::getInstance().setState(tclThread, TclThread::Busy);
+            while (!TclThreadManager::getInstance().isEmpty(tclThread->threadID_))
+            {
                 try
                 {
-                    threadIsReady = lock.try_lock();
-                }
-                catch(boost::lock_error& e){ std::cout << "lockerror thread" << std::endl; }
-
-                if (threadIsReady)
-                {
-                    while (!TclThreadManager::getInstance().isEmpty(threadID))
-                    {
-                        try
-                        {
-std::cout << "1\n";
-std::cout << threadID << std::endl;
-std::string temp = TclThreadManager::getInstance().popCommandFront(threadID);
-std::cout << temp << std::endl;
-                            interpreter->eval(temp);
-std::cout << "2\n";
-                        }
-                        catch (Tcl::tcl_error const &e)
-                        {
-std::cout << "3\n";
-                            TclThreadManager::getInstance().pushCommandBack("error Tcl error (thread " + getConvertedValue<unsigned int, std::string>(threadID) + "): " + e.what());
-                        }
-                        catch (std::exception const &e)
-                        {
-std::cout << "4\n";
-                            TclThreadManager::getInstance().pushCommandBack("error Error while executing tcl (thread " + getConvertedValue<unsigned int, std::string>(threadID) + "): " + e.what());
-                        }
-                        catch (...)
-                        {
-std::cout << "5\n";
-                            TclThreadManager::getInstance().pushCommandBack("error Error while executing tcl (thread " + getConvertedValue<unsigned int, std::string>(threadID) + ").");
-                        }
-                    }
-                }
-            }
-
-            while (TclThreadManager::getInstance().isEmpty(threadID))
+std::cout << "1_1\n";
+                    // mutex threadeval
+                    boost::mutex::scoped_lock lock(*tclThread->evalMutex_);
+                    tclThread->interpreter_->eval(TclThreadManager::getInstance().popCommandFront(tclThread->threadID_));
+std::cout << "1_2\n";
+                }
+                catch (Tcl::tcl_error const &e)
+                {
+                    TclThreadManager::getInstance().pushCommandBack("error Tcl error (thread " + getConvertedValue<unsigned int, std::string>(tclThread->threadID_) + "): " + e.what());
+                }
+                catch (std::exception const &e)
+                {
+                    TclThreadManager::getInstance().pushCommandBack("error Error while executing Tcl (thread " + getConvertedValue<unsigned int, std::string>(tclThread->threadID_) + "): " + e.what());
+                }
+std::cout << "1_4\n";
+            }
+            TclThreadManager::getInstance().setState(tclThread, TclThread::Ready);
+
+            while (TclThreadManager::getInstance().isEmpty(tclThread->threadID_))
+            {
                 boost::this_thread::yield();
-        }
+                if (TclThreadManager::getInstance().getState(tclThread) == TclThread::Finished)
+                    return;
+            }
+        }*/
     }
 }
Index: code/branches/console/src/core/TclThreadManager.h
===================================================================
--- code/branches/console/src/core/TclThreadManager.h	(revision 1230)
+++ code/branches/console/src/core/TclThreadManager.h	(revision 1247)
@@ -45,7 +45,16 @@
     struct TclThread
     {
+        unsigned int threadID_;
         Tcl::interpreter* interpreter_;
         boost::thread* thread_;
-        boost::try_mutex* mutex_;
+        boost::mutex* evalMutex_;
+        boost::mutex* stateMutex_;
+        enum State
+        {
+            Ready,
+            Busy,
+            Finished,
+            Error
+        }* state_;
     };
 
@@ -60,11 +69,16 @@
             static void execute(unsigned int threadID, const std::string& command);
             static std::string query(unsigned int threadID, const std::string& command);
+            static void status();
+            static void dump(unsigned int threadID);
 
+            static std::string tcl_query(int id, Tcl::object const &args);
             static void tcl_execute(Tcl::object const &args);
-            static std::string tcl_orxonox(Tcl::object const &args);
 
             Tcl::interpreter* createTclInterpreter(unsigned int threadID) const;
             bool createTclThread();
             bool destroyTclThread(unsigned int threadID);
+
+            void setState(TclThread* tclThread, TclThread::State state);
+            TclThread::State getState(TclThread* tclThread);
 
             void pushCommandBack(const std::string& command);
@@ -85,14 +99,17 @@
 
             bool isReady_;
+            bool isQuerying_;
+            unsigned int queryID_;
 
             unsigned int IDcount_;
-            std::map<unsigned int, TclThread> threads_;
-            std::map<unsigned int, std::queue<std::string> > threadQueues_;
+            std::map<unsigned int, TclThread*> threads_;
+            std::map<unsigned int, std::pair<std::queue<std::string>, boost::condition*> > threadQueues_;
             std::queue<std::string> orxonoxQueue_;
 
-            boost::mutex orxonoxQueueMutex_;
-            boost::mutex threadQueuesMutex_;
-            boost::mutex threadsMutex_;
-            boost::mutex orxonoxEvalMutex_;
+            boost::try_mutex orxonoxQueueMutex_;
+            boost::try_mutex threadQueuesMutex_;
+            boost::try_mutex threadsMutex_;
+            boost::try_mutex orxonoxStateMutex_;
+            boost::try_mutex orxonoxQueryMutex_;
 
             boost::condition orxonoxQueueCondition_;
@@ -100,5 +117,5 @@
     };
 
-    _CoreExport void tclThreadLoop(Tcl::interpreter* interpreter, boost::try_mutex* mutex, unsigned int threadID);
+    _CoreExport void tclThreadLoop(TclThread* tclThread);
 }
 
