Example of java class semaphore inside matlab
This is just an example how to use the java semaphore class in Matlab.
Includes .m file and respective .fig necessary for running the example.
Matlab is build on top of java so the ideia is to take advantage of that and use functions already on java core. Read more about it here
This will trigger a update function attached to a timer who will print rand() number.
The semaphore will prevent the update function for three seconds After will release it and update can again print random numbers
stops the timer. You can close the figure now
first we need to tell Matlab we want to use that class:
import java.util.concurrent.Semaphore;
After we can use the class methods as typically:
mutex = Semaphore(1);
mutex.availablePermits
all information about the java class is here