Detect running in main thread.

Is there a way, when a method is running in the main thread, to detect the fact that the method is indeed running in the main thread?

Specifically is there a way to do this without referencing any other running threads, since this code needs to be generic and run whether or not other threads exist.

if app.currentThread = nil then // is main thread end if