icount: make it thread-safe