building up thread running code