Added check that a heap is only accessed from the same thread.