Android Open Source - android-bluetooth-serial Thread Manager






From Project

Back to project page android-bluetooth-serial.

License

The source code is released under:

GNU General Public License

If you think the Android project android-bluetooth-serial listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package doctor.bt;
//from  w ww  . jav  a 2 s .  co  m
import android.util.Log;

public class ThreadManager extends Thread {
  
  private BTRemoteDeviceInfo mRemoteDeviceInfo = null;
  private static final String TAG = ThreadManager.class.getName();
  private BTDoctor mBtDoctor = null;
  
  public ThreadManager (BTRemoteDeviceInfo remoteDeviceInfo) {
    this.mRemoteDeviceInfo = remoteDeviceInfo;
  }
  
  public BTDoctor getBtDoctor() {
    return mBtDoctor;
  }

  public void setBtDoctor(BTDoctor btDoctor) {
    this.mBtDoctor = btDoctor;
  }

  public void run() {
    
    int threadCounter = 0;
    
    while (true) {
      try {
        Thread.sleep(5000);
      } catch (InterruptedException e) {
        Log.e(TAG, "error while sleeping!");
        e.printStackTrace();
      }
      
      if (mRemoteDeviceInfo.getmConnStatus() == false) {
        threadCounter++;
        Log.w(TAG, "connection is false, start new client[" + threadCounter + "]:");
        ConnectThread connectThread = new ConnectThread(mRemoteDeviceInfo);
        connectThread.start();            
      }
    }
  }
}




Java Source Code List

doctor.bt.BTDoctor.java
doctor.bt.BTRemoteDeviceInfo.java
doctor.bt.ConnectThread.java
doctor.bt.HttpPostThread.java
doctor.bt.ThreadManager.java