project.lock() (Method)

A means of locking resources that might be shared by several sessions.

Availability:

JavaScript - 1.1
Netscape Enterprise Server version - 2.0
JavaScript syntax:NESproject.lock()

The project lock would be used at a higher hierarchical level than the Lock object that you might use for general purpose locking within a session.

It is even more important that you don't hog a lock on the project object as this can cause severe performance problems.

The lock will stall if another script currently has a lock extant on this project. The method will then return when that lock is relinquished.

If you are accessing files for writing in a server-side application (within NES), you should make sure the project locking is activated to avoid file corruption happening if there are multiple simultaneous accesses to the file.

Example code:

   <SERVER>

   // An example file access with project level locking to prevent

   // file corruption.

   project.lock();

   myFileObject.open("a");

   myFileObject.writeln("Append this line to the file.");

   myFileObject.close();

   project.unlock();

   </SERVER>

See also:File.open(), server.lock()