Lock the thread first thing in init.

Docker-DCO-1.1-Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)
I would move this at the very start of the fuction before we start opening files and everything