Split locking mechanism of statistics gathering and scheduled gathering of statistics. This should improve the responsiveness of the API when a remote call to get statistics is delayed due to network.
Only one calling thread can gather statistics. Other threads meanwhile get the last cached result, even if cache interval is over. Only when there is no statistics available (first time) then callers will block until calling thread returns with an answer.