Added code and psuedo code for thresmain.c