Protect pool idx2ptr and ptr2idx with lock.