added thread functions for native thread handling