create thread logic