There is a 'sync' function in a demo application (jconsole script plugin). This may be of use.

    var sync = function(func, obj) {
        if (arguments.length < 1 || arguments.length > 2 ) {
            throw "sync(function [,object]) parameter count mismatch";
        }

        var syncobj = (arguments.length == 2 ? obj : this);

        if (!syncobj._syncLock) {
            syncobj._syncLock = new Lock();
        }

        return function() {
            syncobj._syncLock.lock();
            try {
                func.apply(null, arguments);
            } finally {
                syncobj._syncLock.unlock();
            }
        };
    };

See also: https://blogs.oracle.com/nashorn/entry/nashorn_multi_threading_and_mt

-Sundar

On Thursday 10 October 2013 03:16 PM, Tal Liron wrote:
How does one create synchronized functions in Nashorn?

Rhino has this facility:

function myFunction() { ... }
myFunction = new org.mozilla.javascript.Synchronizer(myFunction)

Reply via email to