add lock for multi-thread