Java的隐藏功能 [英] Hidden Features of Java
问题描述
阅读 C#隐藏功能后,我想知道,有什么隐藏的功能Java?
After reading Hidden Features of C# I wondered, What are some of the hidden features of Java?
推荐答案
Double Brace Initialization 让我感到意外,之前从未听说过它。
Double Brace Initialization took me by surprise a few months ago when I first discovered it, never heard of it before.
ThreadLocals 通常不是那么广为人知存储每线程状态。
ThreadLocals are typically not so widely known as a way to store per-thread state.
由于JDK 1.5 Java具有非常好的实现和强大的并发工具,而不仅仅是锁,它们存在于 java.util.concurrent 和一个特别有趣的例子是< a href =http://docs.oracle.com /javase/6/docs/api/java/util/concurrent/atomic/package-summary.html\"rel =nofollow noreferrer> java.util.concurrent.atomic 子包,包含实现的线程安全原语比较和交换操作,可以映射到实际的原生硬件支持的这些操作版本。
Since JDK 1.5 Java has had extremely well implemented and robust concurrency tools beyond just locks, they live in java.util.concurrent and a specifically interesting example is the java.util.concurrent.atomic subpackage that contains thread-safe primitives that implement the compare-and-swap operation and can map to actual native hardware-supported versions of these operations.
这篇关于Java的隐藏功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!