more fine locking in write thread