I don't know if that would work for sure (I assume it would), but there's a much better alternative to use anyways; it's basically the exact same thing but automatic. It's called the "Critical Section" action. Basically, you create a global boolean variable for your lock, and then use the critical section action. Anything inside that can only be called by a single caller at once.
Here's an example:
Actions:CriticalSectionusinglock"MyLock"{//Whatever actions are needed here//Note that you don't need to mess with the "MyLock" variable, it's set to true/false automatically at the start and conclusion of this block//No two callers can be running this critical section simultaneously }
Here's the wiki page on multithreading if you want to look up some more details on it.
Hi,
let's say we have the following trigger :
Event : Event X
Actions : Call Function Y [runs in a new thread]
and the Function Y is defined as it follows :
Function Y [ new Thread ] [LockY is a global boolean variable]
All i need is Function Y to be used by only one caller at a time.
Will the above code work ? Or if for example two events that occurs at the exact same time be able to call Function Y and both find LockY false ?
thanks,
Nite.
I don't know if that would work for sure (I assume it would), but there's a much better alternative to use anyways; it's basically the exact same thing but automatic. It's called the "Critical Section" action. Basically, you create a global boolean variable for your lock, and then use the critical section action. Anything inside that can only be called by a single caller at once.
Here's an example:
Here's the wiki page on multithreading if you want to look up some more details on it.
@zeldarules28: Go
Thank you !
That's exactly what i was looking for, it's basically the same as "synchronized" in java. On the wiki page i got all the information i needed.