new Runnable中的 this

package com.test;

public class BB extends AA{

    public String bb = "bbbbb";
public void gg() {
System.out.println("bbgg");
}
public void gg1() {
System.out.println("aagg");
}
}
package com.test;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; public abstract class AA extends CC{
int d = 111; public void gg() {
System.out.println("aagg");
}
public abstract void gg1(); public void ff() {
ExecutorService pool = Executors.newCachedThreadPool();
for(int i = 1; i < 2;i++){
pool.execute(new Runnable() {
Thread thread = Thread.currentThread();
public int ss = 2;
public void gg() {
System.out.println("Runnable gg");
} @Override
public void run() {
AA.this.gg();// this = com.test.AA$1。 里面有属性ss = 2,this$0 = com.test.BB。 调用的BB的gg()
AA.this.gg1();// 调用的BB的gg1()
}
});
}
pool.shutdown();
};
public static void main(String[] args) {
BB x = new BB();
x.ff();
}
}
package com.test;

public class CC {
String ss = "ppp"; private void gg1() {
System.out.println("sssgg1");
}
private void gg() {
System.out.println("sssgg");
}
}
上一篇:win10+anaconda3+python3.6+opencv3.1.0


下一篇:VUE 生命周期 详解