The most common programming error when writing a threaded application is the use of APIs or system services that are not thread safe.
An application needs to be aware of each API that it calls and whether the provider classifies it as thread safe. If the API or system-provided service is thread safe, it must use only other threadsafe APIs or system services in its implementation.
This is especially problematic when your application calls user-written code that is outside of your control. You cannot validate this code for thread safety. If the user code is not threadsafe and you call it within your application's own process context, you might damage the application data, or the application might halt.