主线程中开启子线程代码实例:
创建CancleThread类 继承 Thread,对run()方法进行重写代码实例:
class CancleThread extends Thread
{
private boolean isRun = true;
private boolean isPinStart = false;
//重写Thread类的run()方法
public void run() {
int sleep;
String tip = "PedInputCancel\n";
while(isRun)
{
if(isPinStart)
{
isPinStart = false;
SystemClock.sleep(5000);
Display.appendInfo(tip);
try {
iPed.cancelInput();
} catch (PedDevException e) {
Display.printException(e);
assertTrue(String.format("cancelInput fail errCode=%d\nerrMsg=%s\n",
e.getErrCode(),e.getErrMsg()),e.getErrCode() == 0);
}
}
SystemClock.sleep(1000);