AeroSpatial
New member
- Joined
- Aug 2, 2018
- Messages
- 4
- Reaction score
- 0
- Points
- 0
The following module, in the InitModule implementation, creates a thread
and then waits for it to begin execution.
This deadlocks when Orbiter tries to load it.
Why does this happen? There's no warning in the API documentation to be careful with threads in InitModule, unlike the well-known warnings for DLL entry points.
and then waits for it to begin execution.
This deadlocks when Orbiter tries to load it.
Code:
int g_thread = 0;
DWORD WINAPI ThreadBody(LPVOID lpParam) {
g_thread = 1;
return 0;
}
DLLCLBK void InitModule(HINSTANCE hDLL)
{
CreateThread(0, 0, ThreadBody, 0, 0, 0);
while (!g_thread);
}
Why does this happen? There's no warning in the API documentation to be careful with threads in InitModule, unlike the well-known warnings for DLL entry points.