BUG: race condition when starting threads accessing resources