Code for Batch OS Threads