fixed lock on first run of thread