匿名内部类在多线程中的应用
2016-09-22 14:25
176 查看
package thread; public class InTreadTest { public static void main(String[] args) { //第三第四种利用了匿名内部类,分别是第二、第一种的简写版本 //第一种 Runnable s=new haha(); Thread t=new Thread(s); t.start(); //第二种 Thread w=new hehe(); w.start(); //第三种 new Thread(){ public void run(){ for(int x=0;x<20;x++) System.out.println(x); } }.start(); //第四种 Runnable r=new Runnable(){ public void run(){ for(int x=0;x<20;x++) System.out.println(x); } }; new Thread(r); } } class haha implements Runnable{ public void run(){ for(int x=0;x<20;x++) System.out.println(x); } } class hehe extends Thread{ public void run(){ for(int x=0;x<20;x++) System.out.println(x); } }
相关文章推荐
- C#多线程应用基础
- 在.NET客户端程序中应用多线程
- 多线程的应用
- 多线程在Visual C#网络编程中的应用
- MFC中多线程的应用
- 多线程在Visual C#网络编程中的应用
- MFC中多线程的应用
- MFC中多线程的应用
- ProgressBar控件在Listview下的多线程应用
- 多线程的锁的应用。
- .NET 窗体应用中的多线程误区~~
- C#多线程应用技术面对面探讨
- 一个多线程应用的最佳示例
- delphi中多线程的简单应用
- 在.NET客户端程序中应用多线程
- 多线程的基本概念及其简单应用
- C#多线程应用技术面对面探讨
- C#多线程应用技术面对面探讨[图]
- MFC中多线程的应用
- MFC中多线程的应用