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.
| Constructor and description |
|---|
SynchronizedStatement(Expression expression, Statement code)Constructs a synchronized statement with the given monitor expression and code block. |
| 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) |
| 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 |
Constructs a synchronized statement with the given monitor expression and code block.
expression - the Expression that evaluates to the monitor object to synchronize oncode - the Statement to execute under mutual exclusionReturns the statement executed within the synchronized block.
Returns the monitor expression whose lock is acquired for synchronization.
Sets the statement executed within the synchronized block.
statement - the Statement to execute under mutual exclusionSets the monitor expression whose lock is acquired for synchronization.
expression - the monitor ExpressionCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.