receiverStopping = false;
stopping = false;
   protected void stopReceiver()   {      receiverStopping = true;            //The listener loop may not be waiting, so interrupting the thread will      //not necessarily work, thus leaving it hanging      //so we use the listenerStopping variable too      receiverThread.interrupt();            receiverStopping = false;            }