RestRequest的属性中包含一个SetOnce<XContentType> xcontentType = new SetOnce<>()数据结构,跟踪发现改类存在于org.apache.lucene.util包下;
该集合类可以实现对象 准确的设置一次,多次读取(半不可变semi-immutable);
其实现原理是利用JDK提供的 AtomicReference 的 compareAndSet()操作实现的。
![](https://i-blog.csdnimg.cn/blog_migrate/3e01459b00b891d00f4962c56be5bdf2.png)
RestRequest的属性中包含一个SetOnce<XContentType> xcontentType = new SetOnce<>()数据结构,跟踪发现改类存在于org.apache.lucene.util包下;
该集合类可以实现对象 准确的设置一次,多次读取(半不可变semi-immutable);
其实现原理是利用JDK提供的 AtomicReference 的 compareAndSet()操作实现的。