JAVA匿名实现多线程
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
System.out.println(new Date().toLocaleString() + " start...");
new Thread(
new Runnable(){
public void run()
{
System.out.println(new Date().toLocaleString() + " Thread start");
try
{
java.lang.Thread.sleep(5000);
}
catch(Exception ex)
{
ex.printStackTrace();
}
System.out.println(new Date().toLocaleString() + " Thread end");
}
}
//.run();
).start();
System.out.println(new Date().toLocaleString() + " end.");
输出结果:
2010-4-3 23:45:15 start...
2010-4-3 23:45:15 Thread start
2010-4-3 23:45:15 end.
2010-4-3 23:45:20 Thread end