put the yield-if-not-higher-priority code in a function
Added condition yield code to thread_create()