Regarding the error message:
The symbol lock already refers to the lock function exported from Base. In Julia you can’t have a variable named the same as an (imported) function. Changing your very first line to l = ReentrantLock() should make it work.
2 Likes