Close
Close window
Option lock in procedures - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.
Maplesoft logo
Maplesoft logo

Online Help

All Products Maple MapleSim


[フレーム] [フレーム]

Option lock in Procedures

Calling Sequence

option lock

Description

Adding option lock to a procedure protects that procedure from being run simultaneously with any other option-lock procedure in multiple threads. There can be only one thread running a procedure with option lock at a time. If a second thread tries to run a procedure with option lock, then the second thread will block, waiting until the first thread's procedure is done. Other threads are free to run any other procedure. The thread that "has the lock" is free to run any procedure, including those with option-lock.

Examples

>

p := proc(n)
option lock;
printf("Running p %d\n",n);
Threads:-Sleep(1);
printf("Done p %d\n",n);
end proc:

>

Threads:-Task:-StartNULL,Task=p,1,Task=p,2

Running p 2
Done p 2
Running p 1
Done p 1

Notice that the first procedure that begins to run starts and finishes before the second procedure can begin. Without option lock, you would see two "Running" statements printed before two "Done" statements.


Download Help Document

AltStyle によって変換されたページ (->オリジナル) /