cross platfrom implementation using threads