Does a thread safe operation push a variable?

I have the following Perl code:

push(@myArray, $myValue); 

Is the operation an atom, or do I need to use locks if multiple threads perform the same operation for many threads?

+6
multithreading thread-safety perl reentrant
source share
1 answer

The thread safety of most functions in perl depends on their C routines, and in the case of built-in modules, such as push , there is no mention of thread safety, so you should assume that it is not.

perlthrtut out the perlthrtut man page, in particular the "Basic semaphores" section. Using a semaphore, you can provide mutual exclusion in arbitrary sections of code.

+2
source share

All Articles