If this is done in another thread, you might be missing quite a few locks when using shared resources.