我试图在调用函数时启动新线程,但它给了我
Android: java.lang.IllegalMonitorStateException: object not locked by thread before wait()
这是我的代码
public class webcam_audio_record_V1_4 extends webcam_audio_record implements Command {
private static final int TLV_EXTENSIONS = 20000;
private static final int TLV_TYPE_AUDIO_DURATION = TLVPacket.TLV_META_TYPE_UINT | (TLV_EXTENSIONS + 1);
private static final int TLV_TYPE_AUDIO_DATA = TLVPacket.TLV_META_TYPE_RAW | (TLV_EXTENSIONS + 2);
public int execute(Meterpreter meterpreter, TLVPacket request, TLVPacket response) throws Exception {
int duration = request.getIntValue(TLV_TYPE_AUDIO_DURATION);
Thread thread = new Thread(new Runnable() { public void run() { record(); } });
thread.start();
try { wait(duration * 1000); } catch (InterruptedException e) {}
try { thread.join(); } catch (InterruptedException e) {}
play();
return ERROR_SUCCESS;
}
public void record() {
}
public void play() {
}
我怎样才能在android中成功启动一个线程