「時」Describe a time with “when"
「間」Express something happens during a certain time
「うちに」Do something while (a certain condition remains true)