thread
  instructions

The instructions will be executed in a new threads.

The instructions in the new thread may use local variables of the calling function. These variable will be automatically copyed in the new thread environment.
If you want the new thread not to copy a variable but rather use the original one, you can use the 'share' function to indicate that the variable is common to both threads. If you do so, you have to use semaphores to protect the access to the variable whenever it is required.

share variable


The basic idea with 'parallel' instruction is that a fixed number of tasks will be executed in parallel.

parallel [threads nb_threads] [mini mini_threshold] [maxi maxi_threshold] [active]
  ...
  task
    parallel_instructions
  [post
    sequential_instructions]
  ...

A queue will be created while the body of the 'parallel' instruction is executed. Each time the 'task' instruction is executed, the instructions it contains are queued. Just like in 'thread' instruction, 'share' may be used to specify local variables that have to be passed by address rather than copyed.

The queue will execute 'nb_threads' tasks at once, in parallel will the main thread that runs the body of the 'parallel' instruction in order to fill the queue.
When 'maxi_threshold' items are waiting in the queue, any attempt to put one more will result in:

When the main thread reaches the end of the body of the 'parallel' instruction, depending on 'active' option, it will either start executing tasks from the queue or sleep until the queue gets empty.

When a task contains a 'post' section, the instructions of the 'post' section will be executed sequentially (the ones of the first recorded task will be executed first, then the ones of the second recorded task, and so one). All these post instructions are run in a single another thread.