Spruced up the thread functions by adding loops and yields in the appropriate places.