java匿名类 博客分类: 基础知识
最后看到了这种new Thread(new Runnable()的用法,这里记录一下。
class test {
public static void main(String [] arg){
System.out.println("Hello.");
new Thread(new Runnable(){
public void run(){
System.out.println("I'm the Runnable run.!");
try {
Thread.sleep(1000);
} catch (Throwable e){
e.printStackTrace();
}
System.out.println("I'm the Runnable run..!");
}
}).start();
System.out.println("Hello ..");
}
}
上一篇: JAVA实现异步调用实例代码
推荐阅读
-
Callable 博客分类: 基础知识 java
-
java匿名类 博客分类: 基础知识
-
jstack中的nid的含义 博客分类: 基础知识
-
Java链接MySQL数据库 博客分类: JavaMySQL mysqljavadatabase数据库
-
java的POST 博客分类: 基础知识
-
Java链接Oracle数据库 博客分类: JavaOracle oraclejavajdbc
-
Homebrew最常用 Cheatsheet 博客分类: 基础知识
-
Homebrew最常用 Cheatsheet 博客分类: 基础知识
-
Redis分布式锁java版 博客分类: 分布式锁 javaredis
-
安装 Siemens Java MTK 需要JRE1.4, 可我只有1.6 博客分类: J2ME MTKJavaMobileNokiaMicrosoft