站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2SE 专题请问这一句是什么意思呀

请问这一句是什么意思呀

摘要: 请问这一句是什么意思呀


我在网上找了个程序。
public class Test1 extends Thread{
static int count = 0;
int number;
public Test1(int num){
number = num;
}
public void run(){
while(count<30){
//synchronized(this){
count++;
//}
System.out.println ("线程"+number+":"+count);
}
}

public static void main(String[] args){
for(int i=0; i<3;i++)
new Test1(i).start();-------->就是这句,请问这里的start()是什么意思呀,这个
}                  Test1类中没有这个意思呀
}


start()是继承自Thread的方法,一执行这个方法就启动这个线程了,即执行Test的run()方法。


在java中方法就是线程吗



new Test1(i).start();它这一句中的Test1(i)是个成员函数,还是一个类呀

new Test1(i).start();

同等于:
Test1 t=new Test1(); //创建一个类成员对象
t.Test1(i=0 to 2) //构造函数(方法),对类进行初始化// 不好意思,这里用到VB的数组,V            B的数组好懂些~~~
t.start();   //启动线程~~~
t.Test1(i=0 to 2) //构造函数(方法),对类进行初始化

写错了~~
下面才是对的
t.Test1(i=0 to 2) //构造函数(方法),对当前类进行初始化
嗯,好的,谢谢


↑返回目录
前一篇: 初学线程,简单的计数程序,帮忙看看
后一篇: JAVA GUI客户端和SERVER通讯的问题