Fix concurrency problems in SharedResource and BufferPool