If you want to use Threads, you have to enable "Thread Safe" in the compiler settings:
Create thread-safe executable
This tells the compiler to use a special version of certain commands to make them safe to be used in threads. See the Thread library for more information.
This also enables the Debugger to display correct information if threads are used. Without this option, the debugger might output wrong line numbers when threads are involved for example.