我刚刚在看Java的ConcurrentHashMap的源代码,发现这行代码:
/*
* The maximum number of times to tryLock in a prescan before possibly blocking on acquire in
* preparation for a locked segment operation. On multiprocessors, using a bounded number of
* retries maintains cache acquired while locating nodes.
*/
static final int MAX_SCAN_RETRIES =
Runtime.getRuntime().availableProcessors() > 1 ? 64 : 1
用于在MAX_SCAN_RETRIES
获取锁时查找条目。我的问题是如何64
确定多处理器机器的数量?有人知道这个数字背后的理论64
吗?