Begin critical block

20% Command group 20% Flag affected 20% Reversible 20% Execute on client 20% Platform(s)
Threads NO NO NO All

Syntax

Begin critical block

Description

Begin critical block is only applicable to the multithreaded server. It marks the start of a critical block, namely a section of code which needs to execute in single threaded mode without allowing other client methods to execute. You use End critical block to mark the end of a critical block.

One example of when you should use a critical block is as follows. Class variables are shared by all clients. Simple atomic operations, such as the direct assignment of a value to a class variable are safe. Other operations, such as when a method call is involved, could cause problems, because the method call might be interrupted by another thread. To avoid this, use a critical block.

Example

Begin critical block
  Calculate cClassVar as $cinst.$getvalue()
End critical block