Added affinity stuff to thread_init()