我不明白这段代码。请解释... [英] I dont understand this code. Please explain...
本文介绍了我不明白这段代码。请解释...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
线程t1 =新线程(){
public void run(){
for(int i = 1; i< = 10; i ++)
{
System.out.println(i);
}
}
};
Thread t1 = new Thread(){
public void run(){
for(int i = 1;i <= 10;i++)
{
System.out.println(i);
}
}
};
推荐答案
与下面的代码相同。它创建一个带有函数作为参数的线程。启动线程执行函数。
Same as below Code. It creates a thread with a function as argument. starting the thread executes the function.
Thread t1 = new Thread(new ThreadStart(run));
t1.Start();
public void run()
{
for(int i = 1;i <= 10;i++)
{
System.out.println(i);
}
}
得到它。这是一个匿名的类概念。我之前没有听说过irt,所以我不明白代码。
got it. It was anonymous class concept. I haven't actually heard about irt before so I didn't understand the code.
这篇关于我不明白这段代码。请解释...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文