server.c, add thread lock