Java 流式操作 Stream(15) lambda表达式与匿名内部类的this指向
package com.lius.stream;
/**
* <p>lambda表达式与匿名内部类的this指向</p>
*/
public class streamTest10 {
//lambda
private Runnable r1 = ()->System.out.println(this);
//匿名内部类
private Runnable r2 = new Runnable() {
@Override
public void run() {
System.out.println(this);
}
};
public static void main(String[] args) {
streamTest10 streamTest10 = new streamTest10();
streamTest10.TestStreamTest10();
}
public void TestStreamTest10(){
Thread t1 = new Thread(r1);
t1.start();
System.out.println("*******************");
Thread t2 = new Thread(r2);
t2.start();
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/d24aa140a4a07666cb53fa92d5ac2787.png)