Java学习笔记——线程两种惯用的创建调用方法

Java学习笔记——线程两种常用的创建调用方法

这是两种开发中常用的线程使用方法,匿名对象调用即可,很简单,掌握即可

<span style="font-size:18px;">class ThreadDemo 
{
	public static void main(String[] args) 
	{
		new Thread()
		{
			public void run()
			{
				//coding here
			}

		}.start();

		Runnable r = new Runnable()
		{
			public void run()
			{
				//coding here
			}
		};
		new Thread(r).start();
	}
}
</span>