Skip to content

JSX Lock

hxs edited this page Nov 27, 2019 · 4 revisions

JSX-Lock

JSX-Lock is the implementation of java.util.concurrent.locks.ReentrantLock class, on the JSX library.
With this feature you can lock the log file automatically or implement your lock with the override of methods tryLock() and tryUnlock() of JSX class.

Use it

To use this function, just activate the lock with the function setLock(true) of the class JSX. Automatically the write and read methods, check if the XML file is locked, and if the file is free then lock it and start with the operation.

The method tryLock() raise the JSXLockException, if the timeout expire.

Example:

JSX jsx = new JSX("path/to/file.xml");
jsx.setLock(true);
// now the writer and reader method use JSX-Lock
jsx.addElement("new-element");
Clone this wiki locally