fixed an unsynchronized bug

the stat info should be updated in a critical section