2020
10-10
10-10
Java获取线程ID的实例
以下实例演示了如何使用getThreadId()方法获取线程id:publicclassMainextendsObjectimplementsRunnable{privateThreadIDvar;publicMain(ThreadIDv){this.var=v;}publicvoidrun(){try{print("vargetThreadID="+var.getThreadID());Thread.sleep(2000);print("vargetThreadID="+var.getThreadID());}catch(InterruptedExceptionx){}}privatestaticvoidprint(Stringm...
继续阅读 >