CommandInterrupter

public class CommandInterrupter
extends Object

java.lang.Object
com.android.tradefed.command.CommandInterrupter


此服务允许中断 TradeFederation 命令或将其标记为不可中断。

摘要

字段

public static final CommandInterrupter INSTANCE

单例。

公共构造函数

CommandInterrupter()

公共方法

void allowInterrupt()

允许中断当前线程。

Future<?> allowInterruptAsync(Thread thread, long delay, TimeUnit unit)

允许在延迟后中断指定线程。

void blockInterrupt()

阻止中断当前线程。

void checkInterrupted()

如果应中断当前线程,则中断该线程。

void interrupt(Thread thread, String message, ErrorIdentifier errorId)

标记线程,并在线程变为可中断时中断该线程。

boolean isInterruptible(Thread thread)
boolean isInterruptible()

字段

INSTANCE

public static final CommandInterrupter INSTANCE

单例。

公共构造函数

CommandInterrupter

public CommandInterrupter ()

公共方法

allowInterrupt

public void allowInterrupt ()

允许中断当前线程。

allowInterruptAsync

public Future<?> allowInterruptAsync (Thread thread, 
                long delay, 
                TimeUnit unit)

允许在延迟后中断指定线程。

参数
thread Thread:要标记为可中断的线程

delay long:从现在开始延迟执行的时间

unit TimeUnit:延迟参数的时间单位

返回
Future<?>

blockInterrupt

public void blockInterrupt ()

阻止中断当前线程。

checkInterrupted

public void checkInterrupted ()

如果应中断当前线程,则中断该线程。建议线程定期调用此方法,以便抛出正确的 RunInterruptedException

抛出
RunInterruptedException

interrupt

public void interrupt (Thread thread, 
                String message, 
                ErrorIdentifier errorId)

标记线程,并在线程变为可中断时中断该线程。

参数
thread Thread:要标记为中断的线程

message String:中断消息

errorId ErrorIdentifier

isInterruptible

public boolean isInterruptible (Thread thread)

参数
thread Thread

返回
boolean 如果指定线程可中断,则为 true

isInterruptible

public boolean isInterruptible ()

返回
boolean 如果当前线程可中断,则为 true