[runtime] Use a separate lock to protect global data structures in classes.c.