Search code examples
nashorn

Nashorn : synchronized methods and blocks


Straightforward question : how to mark methods and blocks of code as synchronized in js scripts. Also a way to implement the volatile keyword


Solution

  • As Javascript (Browser and Node.js) run single threaded there is no need to mark methods as synchronized. afaik Nashorn is not yet multithreaded (see https://blogs.oracle.com/nashorn/entry/nashorn_multi_threading_and_mt)