Package: org.codehaus.groovy.ast.stmt

## [Java] Class SynchronizedStatement

- org.codehaus.groovy.ast.stmt.SynchronizedStatement

-     public class SynchronizedStatement
      extends Statement

  Represents a synchronized statement that provides mutual exclusion for a code block. A synchronized statement acquires a lock on the monitor associated with the control expression before executing the code block, ensuring that only one thread can execute the synchronized block at a time for the given monitor object.

  See Also:
    Expression
    Statement

- - ### Constructor Summary

    Constructors
    Constructor and description
    `SynchronizedStatement(Expression expression, Statement code)` Constructs a synchronized statement with the given monitor expression and code block.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public Statement` | `getCode()` Returns the statement executed within the synchronized block.
    `` | `public Expression` | `getExpression()` Returns the monitor expression whose lock is acquired for synchronization.
    `` | `public void` | `setCode(Statement statement)` Sets the statement executed within the synchronized block.
    `` | `public void` | `setExpression(Expression expression)` Sets the monitor expression whose lock is acquired for synchronization.
    `` | `public void` | `visit(GroovyCodeVisitor visitor)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Statement` | `addStatementAnnotation, addStatementLabel, copyStatementLabels, getStatementAnnotations, getStatementLabel, getStatementLabels, isEmpty, setStatementLabel`
    `class ASTNode` | `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit`

- - ### Constructor Detail

    - #### public SynchronizedStatement(Expression expression, Statement code)

      Constructs a synchronized statement with the given monitor expression and code block.

      Parameters:
        `expression` - the Expression that evaluates to the monitor object to synchronize on
        `code` - the Statement to execute under mutual exclusion

  - ### Method Detail

    - #### public Statement getCode()

      Returns the statement executed within the synchronized block.

      Returns:
        the Statement executed under mutual exclusion

    - #### public Expression getExpression()

      Returns the monitor expression whose lock is acquired for synchronization.

      Returns:
        the monitor Expression

    - #### public void setCode(Statement statement)

      Sets the statement executed within the synchronized block.

      Parameters:
        `statement` - the Statement to execute under mutual exclusion

    - #### public void setExpression(Expression expression)

      Sets the monitor expression whose lock is acquired for synchronization.

      Parameters:
        `expression` - the monitor Expression

    - #### public void visit(GroovyCodeVisitor visitor)