Index: libs/libmythtv/analogscan.h
===================================================================
--- libs/libmythtv/analogscan.h	(revision 10392)
+++ libs/libmythtv/analogscan.h	(working copy)
@@ -35,6 +35,8 @@
 
 #include <qobject.h>
 #include <qstring.h>
+#include <qmutex.h>
+#include <qwaitcondition.h>
 #include <pthread.h>
 #include "frequencies.h"
 
@@ -90,6 +92,10 @@
     /** @brief Scanning thread*/
     pthread_t thread;
 
+    /** @brief Condition to signal that the scanning thread is running */
+    QWaitCondition scanThreadCond;
+    QMutex scanThreadCondLock;
+
     /** @brief Actual scanning proc */
     void doScan();
     /** @brief Actual thread proc , calls doScan*/
Index: libs/libmythtv/tv_play.h
===================================================================
--- libs/libmythtv/tv_play.h	(revision 10392)
+++ libs/libmythtv/tv_play.h	(working copy)
@@ -567,6 +567,10 @@
     /// runs pipnvp's NuppelVideoPlayer::StartPlaying().
     pthread_t pipdecode;
 
+    /// Condition to signal that the Event thread is up and running
+    QWaitCondition mainLoopCond;
+    QMutex mainLoopCondLock;
+
     // Constants
     static const int kInitFFRWSpeed; ///< 1x, default to normal speed
     static const int kMuteTimeout;   ///< Channel changing mute timeout in msec
Index: libs/libmythtv/analogscan.cpp
===================================================================
--- libs/libmythtv/analogscan.cpp	(revision 10392)
+++ libs/libmythtv/analogscan.cpp	(working copy)
@@ -76,6 +76,9 @@
 void AnalogScan::doScan()
 {
     fRunning = true;
+    scanThreadCondLock.lock();
+    scanThreadCond.wakeAll();
+    scanThreadCondLock.unlock();
 
     Channel         *channel = NULL;
     struct CHANLIST *flist   = NULL;
@@ -156,9 +159,13 @@
     }
 
     if (!fRunning)
+    {
+        scanThreadCondLock.lock();
         pthread_create(&thread, NULL, spawn, this);
-    while (!fRunning)
-        usleep(50);
+        scanThreadCond.wait(&scanThreadCondLock);
+        scanThreadCondLock.unlock();
+    }
+
     return true;
 }
 
Index: libs/libmythtv/RingBuffer.cpp
===================================================================
--- libs/libmythtv/RingBuffer.cpp	(revision 10392)
+++ libs/libmythtv/RingBuffer.cpp	(working copy)
@@ -629,10 +629,10 @@
 {
     readaheadrunning = false;
 
+    readAheadRunningCondLock.lock();
     pthread_create(&reader, NULL, StartReader, this);
-
-    while (!readaheadrunning)
-        usleep(50);
+    readAheadRunningCond.wait(&readAheadRunningCondLock);
+    readAheadRunningCondLock.unlock();
 }
 
 /** \fn RingBuffer::KillReadAheadThread(void)
@@ -730,6 +730,9 @@
     totfree = ReadBufFree();
 
     readaheadrunning = true;
+    readAheadRunningCondLock.lock();
+    readAheadRunningCond.wakeAll();
+    readAheadRunningCondLock.unlock();
     while (readaheadrunning)
     {
         if (pausereadthread || writemode)
Index: libs/libmythtv/tv_play.cpp
===================================================================
--- libs/libmythtv/tv_play.cpp	(revision 10392)
+++ libs/libmythtv/tv_play.cpp	(working copy)
@@ -484,11 +484,11 @@
         qApp->processEvents();
     }
 
+    mainLoopCondLock.lock();
     pthread_create(&event, NULL, EventThread, this);
+    mainLoopCond.wait(&mainLoopCondLock);
+    mainLoopCondLock.unlock();
 
-    while (!runMainLoop && !IsErrored())
-        usleep(50);
-
     return !IsErrored();
 }
 
@@ -1084,9 +1084,8 @@
  */
 bool TV::InStateChange() const
 {
-    if (stateLock.locked())
+    if (!stateLock.tryLock())
         return true;
-    stateLock.lock();
     bool inStateChange = nextStates.size() > 0;
     stateLock.unlock();
     return inStateChange;
@@ -1309,10 +1308,10 @@
         nvp->SetWatchingRecording(true);
 
     int udp_port = gContext->GetNumSetting("UDPNotifyPort");
-     if (udp_port > 0)
-         udpnotify = new UDPNotify(this, udp_port);
-     else
-         udpnotify = NULL;
+    if (udp_port > 0)
+        udpnotify = new UDPNotify(this, udp_port);
+    else
+        udpnotify = NULL;
 }
 
 
@@ -1503,6 +1502,10 @@
     runMainLoop = true;
     exitPlayer = false;
 
+    mainLoopCondLock.lock();
+    mainLoopCond.wakeAll();
+    mainLoopCondLock.unlock();
+
     while (runMainLoop)
     {
         stateLock.lock();
Index: libs/libmythtv/RingBuffer.h
===================================================================
--- libs/libmythtv/RingBuffer.h	(revision 10392)
+++ libs/libmythtv/RingBuffer.h	(working copy)
@@ -173,6 +173,10 @@
 
     long long readAdjust;
 
+    /// Condition to signal that the read ahead thread is running
+    QWaitCondition readAheadRunningCond;
+    QMutex readAheadRunningCondLock;
+ 
     // constants
     static const uint kBufferSize;
     static const uint kReadTestSize;
Index: programs/mythfrontend/networkcontrol.h
===================================================================
--- programs/mythfrontend/networkcontrol.h	(revision 10392)
+++ programs/mythfrontend/networkcontrol.h	(working copy)
@@ -66,8 +66,6 @@
     QMutex nrLock;
 
     pthread_t command_thread;
-    bool runCommandThread;
-    bool commandThreadRunning;
 };
 
 #endif
Index: programs/mythfrontend/networkcontrol.cpp
===================================================================
--- programs/mythfrontend/networkcontrol.cpp	(revision 10392)
+++ programs/mythfrontend/networkcontrol.cpp	(working copy)
@@ -103,8 +103,6 @@
     keyMap["f11"]                    = Qt::Key_F11;
     keyMap["f12"]                    = Qt::Key_F12;
 
-    runCommandThread = true;
-
     pthread_attr_t attr;
     pthread_attr_init(&attr);
     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
@@ -123,11 +121,7 @@
 
     notifyDataAvailable();
 
-    runCommandThread = false;
-
-    while (commandThreadRunning)
-        usleep(1000);
-
+    pthread_cancel(command_thread);
     pthread_join(command_thread, NULL);
 }
 
@@ -143,10 +137,11 @@
 {
     QString command;
     int commands = 0;
-    commandThreadRunning = true;
 
-    while(runCommandThread)
+    for (;;)
     {
+        pthread_testcancel();
+
         ncLock.lock();
         commands = networkControlCommands.size();
         ncLock.unlock();
@@ -167,8 +162,6 @@
 
         usleep(50000);
     }
-
-    commandThreadRunning = false;
 }
 
 void NetworkControl::processNetworkControlCommand(QString command)
