runWithScissors
来源:互联网 发布:男人很脆弱知乎 编辑:程序博客网 时间:2024/05/11 02:59
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.2.2_r1/android/os/Handler.java
Runs the specified task synchronously. If the current thread is the same as the handler thread, then the runnable runs immediately without being enqueued. Otherwise, posts the runnable to the handler and waits for it to complete before returning. This method is dangerous! Improper use can result in deadlocks. Never call this method while any locks are held or use it in a possibly re-entrant manner. This method is occasionally useful in situations where a background thread must synchronously await completion of a task that must run on the handler's thread. However, this problem is often a symptom of bad design. Consider improving the design (if possible) before resorting to this method. One example of where you might want to use this method is when you just set up a Handler thread and need to perform some initialization steps on it before continuing execution. If timeout occurs then this method returnsfalse
but the runnable will remain posted on the handler and may already be in progress or complete at a later time.
- Parameters:
r
The Runnable that will be executed synchronously.timeout
The timeout in milliseconds, or 0 to wait indefinitely.- Returns:
- Returns true if the Runnable was successfully executed. Returns false on failure, usually because the looper processing the message queue is exiting.
- Hide:
- This method is prone to abuse and should probably not be in the API. If we ever do make it part of the API, we might want to rename it to something less funny like runUnsafe().
448
449
public final boolean runWithScissors(final Runnable r, long timeout) {
450
if (r == null) {
451
throw new IllegalArgumentException("runnable must not be null");
452
}
453
if (timeout < 0) {
454
throw new IllegalArgumentException("timeout must be non-negative");
455
}
456
457
if (Looper.myLooper() == mLooper) {
458
r.run();
459
return true;
460
}
461
462
BlockingRunnable br = new BlockingRunnable(r);
463
return br.postAndWait(this, timeout);
464
}
- runWithScissors
- 布局文件提示错误“No orientation specified, and the default is horizontal. This is a common so...”
- 【认识aspx】页面处理程序【页面生成关系】【页面继承关系】
- 通过网页链接打开应用程序
- 真封神之天尊地魔引擎修改系列教程
- 文章
- runWithScissors
- LINUX下目录文件的遍历---编程
- (转)Android图形系统分析与移植--六、framebuffer研究
- 输入年月输出该月天数(改良版)
- spring整合groovy异常:FileNotFoundException
- Codeforces Round #214 (Div. 2) C. Dima and Salad
- 服务器架构设计3------状态机的使用
- Delphi版本的淘宝接口(TopAPI)开发
- 暴力求解法-简单枚举