Added timer interrupt to switch threads in real time