added support for thread scheduling