When I try to debug threads , the PB Debugger often uses bad addresses and crashes. If I compile "Without Debugger" , each thread runs correctly (Windows 7, Intel 64-bit hex core). Is there something I should do for threadsafe variable/value inspection inside Procedure DoTheWork(*ThreadID) when compiling "With Debugger"?
For ICreate = 1 To NThreads : AllThreads(ICreate) = CreateThread(@DoTheWork(), ICreate) : Delay(50) : Next ICreate
For IWait = 1 To NThreads : WaitThread(AllThreads(IWait)) : Delay(50) : Next IWait ;Without a delay between OS thread calls PureBasic will crash.
I did not include complete source code because as I said, everything is working like a charm without the Debugger. The test program breaks up a loop so that a loop requiring 10 seconds of work finishes in under 2 seconds with 10 threads all doing their share. Race conditions in thread code are avoided because the threads work in their own global space. MAIN sets up the global input data before threads start and waits until they finish to use the results.