Created template for scheduler, templates for saveThreadState and restoreThreadState