Page 1 of 1

Thread BUG?

Posted: Wed Aug 28, 2019 7:33 pm
by AtomUpgrader

Code: Select all

Global test.l

Procedure AlertThread(Parameter)
Repeat
test + 1
Debug "1: " + str(test)
Delay(2000)
ForEver
EndProcedure

CreateThread(@AlertThread(), 0)
Repeat
Debug "2: " + str(test)
Delay(2000)
ForEver
Displayed
2: 0
1: 1
2: 11潳䱲瑥整ㅲ
1: 2
1: 32‱‽റ㬊䌠
2: 3
2: 1:
2: 1:
1: 52
2: 5
This is my first experience with threads and what am I doing wrong?

Re: Thread BUG?

Posted: Wed Aug 28, 2019 7:41 pm
by STARGÅTE
No Bug!

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.

Code: Select all

CompilerIf #PB_Compiler_Thread = #False
	CompilerError "Enable Thread Safe"
CompilerEndIf

Re: Thread BUG?

Posted: Wed Aug 28, 2019 10:07 pm
by Little John
AtomUpgrader wrote:This is my first experience with threads and what am I doing wrong?
Please don't ask your coding questions in the "Bug reports" section of the forum. Thank you.

Also
Please read before submitting a bug report !

Re: Thread BUG?

Posted: Thu Aug 29, 2019 5:34 am
by AtomUpgrader
Sorry, ok :oops: