window: use a better LockOSThread pattern; Related to #39