Code example for Thread

Methods: start

0
    public Sender(Socket sock) throws IOException {
      toSend = new SynchronousQueue<String>();
      output = new DataOutputStream(sock.getOutputStream());
 
      // Start thread : 
      execThread = new Thread(this);
      execThread.start();
    } 
 
    public void stop() { 
      Log.d(LOGTAG, "Stopping sender");
      synchronized(this) {
        Log.d(LOGTAG, "in the stop synchronized");
        stopped = true;
      } 
 
      Log.d(LOGTAG, "Flag set");
      try { 
        toSend.put("");
      } catch (Exception e) {
        Log.d(LOGTAG, "Could not send empty terminating message in queue : " + e.getMessage());