g***r 发帖数: 281 | 1 Runnable t = new Runnable() {
public void run()
{ //....
}
};
Thread t1 = new Thread (t);
t1.start();
这段code比较奇怪, 我以为应该是语法错, 但是却能运行,咋回事? | xt 发帖数: 17532 | 2
一点都不古怪.我整天写这玩意.见Thread的constructor.
【在 g***r 的大作中提到】 : Runnable t = new Runnable() { : public void run() : { //.... : } : }; : Thread t1 = new Thread (t); : t1.start(); : 这段code比较奇怪, 我以为应该是语法错, 但是却能运行,咋回事?
| c*y 发帖数: 137 | 3 Runnable is an interface, and this is like defining an inner class. If you
want to be formal, you can always first define a class which implements
Runnable, then you use that class.
【在 g***r 的大作中提到】 : Runnable t = new Runnable() { : public void run() : { //.... : } : }; : Thread t1 = new Thread (t); : t1.start(); : 这段code比较奇怪, 我以为应该是语法错, 但是却能运行,咋回事?
|
|