Merge "Better detecting if current threasd is main thread"