If you ever have an optimization running and you only have 2 license of something and unlimited licenses of something else. The project might help you with assigning lock files. What I did was create an array using 4 lock files. I then have a loop where I launch 50 instances of an execution with 4 lock files. So only 4 executions can occur at a given time.
To run the code just run launch_lock_test.sh and you should see the execution happening in the termianl.