threads: actually fix if we write to many files at once

Change-Id: Iaff1fee8e39e85be7502f75bb5d1835d6766d23c