In the following module, lock annotations are used to prevent concurrent write operations on the same file:
<pre classsyntaxhighlight lang="brush:xquery">
module namespace config = 'config';
file:write-text('config.txt', $data)
};
</presyntaxhighlight>
Some explanations:
Local locks can also be declared via pragmas:
<pre classsyntaxhighlight lang="brush:xquery">
(# basex:write-lock CONFIG #) {
file:write('config.xml', <config/>)
}
</presyntaxhighlight>
Locks for the functions of a module can be assigned via option declarations:
<pre classsyntaxhighlight lang="brush:xquery">
declare option basex:write-lock 'CONFIG';
file:write('config.xml', <config/>)
</presyntaxhighlight>
===Java Modules===