Replaced usage of CreateTHread with _beginthreadex
Updated invalid thread handle value and implemented thread id and handle type conversion at the _beginthreadex call