short example of the bug...
Code: Select all
Declare.l thread1(var.l)
Declare.l thread2(var.l)
Declare.l thread3()
Global lock.l
lock = CreateMutex()
OpenWindow(0,0,0,320,40,"Window",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
TextGadget(1, 10, 10, 300, 20, "")
EndIf
CreateThread(@thread1(), 0)
CreateThread(@thread2(), 0)
CreateThread(@thread1(), 0)
CreateThread(@thread2(), 0)
; this will cause a deadlock if thread3() is called..
; if thread3() was removed from the loop no deadlock occurs
Repeat : thread3() : Until WindowEvent()=#PB_Event_CloseWindow
Procedure.l thread1(var.l)
Repeat
LockMutex(lock)
SetGadgetText(1, "thread1")
UnlockMutex(lock)
Delay(1)
ForEver
EndProcedure
Procedure.l thread2(var.l)
Repeat
LockMutex(lock)
SetGadgetText(1, "thread2")
UnlockMutex(lock)
Delay(1)
ForEver
EndProcedure
Procedure.l thread3()
LockMutex(lock)
SetGadgetText(1, "thread3")
UnlockMutex(lock)
Delay(1)
EndProcedure
if you remove the thread3() call as stated in the comment it will work just fine,
but getting no response at all after compile if i let the thread3() call as it.
i don't exactly know what the real cause of this is but anyway, need this to be working!