Index: trunk/FACT++/src/StateMachineImp.cc
===================================================================
--- trunk/FACT++/src/StateMachineImp.cc	(revision 14123)
+++ trunk/FACT++/src/StateMachineImp.cc	(revision 14124)
@@ -384,5 +384,5 @@
 //!    The event names all have the SERVER/ pre-fix removed.
 //
-const vector<string> StateMachineImp::GetEventNames() const
+const vector<string> StateMachineImp::GetEventNames()
 {
     vector<string> v;
@@ -391,4 +391,6 @@
     const int     len  = name.length();
 
+    const lock_guard<mutex> guard(fMutexEvt);
+
     for (vector<EventImp*>::const_iterator i=fListOfEvents.begin();
          i!=fListOfEvents.end(); i++)
@@ -413,6 +415,8 @@
 //!    if given only the given event is selected
 //
-void StateMachineImp::PrintListOfEvents(ostream &out, const string &evt) const
-{
+void StateMachineImp::PrintListOfEvents(ostream &out, const string &evt)
+{
+    const lock_guard<mutex> guard(fMutexEvt);
+
     for (vector<EventImp*>::const_iterator c=fListOfEvents.begin(); c!=fListOfEvents.end(); c++)
         if (evt.empty() || GetName()+'/'+evt==(*c)->GetName())
@@ -429,6 +433,8 @@
 //!
 //
-void StateMachineImp::PrintListOfAllowedEvents(ostream &out) const
-{
+void StateMachineImp::PrintListOfAllowedEvents(ostream &out)
+{
+    const lock_guard<mutex> guard(fMutexEvt);
+
     for (vector<EventImp*>::const_iterator c=fListOfEvents.begin(); c!=fListOfEvents.end(); c++)
         if ((*c)->IsStateAllowed(fCurrentState))
@@ -444,5 +450,5 @@
 //
 //
-void StateMachineImp::PrintListOfEvents(const string &str) const
+void StateMachineImp::PrintListOfEvents(const string &str)
 {
     PrintListOfEvents(Out(), str);
@@ -485,7 +491,8 @@
 //!    true if the event was found, false otherwise
 //
-bool StateMachineImp::HasEvent(const EventImp *cmd) const
+bool StateMachineImp::HasEvent(const EventImp *cmd)
 {
     // Find the event from the list of commands and queue it
+    const lock_guard<mutex> guard(fMutexEvt);
     return find(fListOfEvents.begin(), fListOfEvents.end(), cmd)!=fListOfEvents.end();
 }
@@ -500,7 +507,8 @@
 //!    true if the event was found, false otherwise
 //
-EventImp *StateMachineImp::FindEvent(const string &evt) const
+EventImp *StateMachineImp::FindEvent(const string &evt)
 {
     // Find the command from the list of commands and queue it
+    const lock_guard<mutex> guard(fMutexEvt);
     for (vector<EventImp*>::const_iterator c=fListOfEvents.begin(); c!=fListOfEvents.end(); c++)
         if (evt == (*c)->GetName())
@@ -546,5 +554,7 @@
 #endif
 
+    fMutexEvt.lock();
     fListOfEvents.push_back(evt);
+    fMutexEvt.unlock();
 
     return *evt;
@@ -611,6 +621,22 @@
 {
     EventImp *evt = CreateService(name);
+
+    fMutexEvt.lock();
     fListOfEvents.push_back(evt);
+    fMutexEvt.unlock();
+
     return *evt;
+}
+
+void StateMachineImp::Unsubscribe(EventImp *evt)
+{
+    const lock_guard<mutex> guard(fMutexEvt);
+
+    auto it = find(fListOfEvents.begin(), fListOfEvents.end(), evt);
+    if (it==fListOfEvents.end())
+        return;
+
+    fListOfEvents.erase(it);
+    delete evt;
 }
 
Index: trunk/FACT++/src/StateMachineImp.h
===================================================================
--- trunk/FACT++/src/StateMachineImp.h	(revision 14123)
+++ trunk/FACT++/src/StateMachineImp.h	(revision 14124)
@@ -41,5 +41,6 @@
     std::queue<Event*>     fEventQueue;   /// Event queue (fifo) for the received commands
 
-    std::mutex fMutex;   /// Mutex to ensure thread-safe access to the command fifo
+    std::mutex fMutex;    /// Mutex to ensure thread-safe access to the command fifo
+    std::mutex fMutexEvt; /// Mutex to ensure thread-safe access to the command fifo
 
     bool fRunning;       /// Machine is in main-loop
@@ -101,4 +102,5 @@
 
     EventImp &Subscribe(const std::string &name);
+    void Unsubscribe(EventImp *evt);
 
     /// return the current state of the machine
@@ -128,17 +130,17 @@
 
     // Event handling
-    bool HasEvent(const EventImp *cmd) const;
-    EventImp *FindEvent(const std::string &evt) const;
+    bool HasEvent(const EventImp *cmd);
+    EventImp *FindEvent(const std::string &evt);
 
     bool IsQueueEmpty() const { return fEventQueue.size()==0; }
 
-    const std::vector<EventImp*> &GetListOfEvents() const { return fListOfEvents; }
-    const std::vector<std::string> GetEventNames() const;
-
-    void PrintListOfEvents(std::ostream &out, const std::string &evt="") const;
-    void PrintListOfEvents(const std::string &str="") const;
-
-    void PrintListOfAllowedEvents(std::ostream &out) const;
-    void PrintListOfAllowedEvents() const;
+    //const std::vector<EventImp*> &GetListOfEvents() const { return fListOfEvents; }
+    const std::vector<std::string> GetEventNames();
+
+    void PrintListOfEvents(std::ostream &out, const std::string &evt="");
+    void PrintListOfEvents(const std::string &str="");
+
+    void PrintListOfAllowedEvents(std::ostream &out);
+    void PrintListOfAllowedEvents();
 
     void PrintListOfStates(std::ostream &out) const;
