PendingInterrupt.java
资源名称:Source.rar [点击查看]
上传用户:songled
上传日期:2022-07-14
资源大小:94k
文件大小:0k
源码类别:
进程与线程
开发平台:
Java
- public class PendingInterrupt extends Object {
- public static void main(String[] args) {
- if ( args.length > 0 ) {
- Thread.currentThread().interrupt();
- }
- long startTime = System.currentTimeMillis();
- try {
- Thread.sleep(2000);
- System.out.println("was NOT interrupted");
- } catch ( InterruptedException x ) {
- System.out.println("was interrupted");
- }
- System.out.println(
- "elapsedTime=" + ( System.currentTimeMillis() - startTime ));
- }
- }