Hi, how can I check the current thread is main thr...
# kotlin-native
j
Hi, how can I check the current thread is main thread in Linux?
m
I guess it depends what framework you're using ? If you're making a simple cli, you can always set a thread local variable att tthe beginning of your main ?
s
@Jeff Beyond Since Posix & Linux APIs are available in Kotlin/Native, this should help: https://stackoverflow.com/questions/20530218/check-if-current-thread-is-main-thread
👍 4
Basically:
Copy code
getpid() == gettid()
👍 1