Make partial mocks thread safe

Partial mocks use a shared table. Without this patch, concurrent accesses to
the shared table will cause crashes.