added function bool IsMainThread()

By calling it you can determine if your current thread is the main thread.
You can use that function to add error-trapping code which detects when e.g. GTK GUI controls are manipulated from a non-main thread.
Doing that will usually break things. So we need to be able to find those occurrences and investigate them more closely.