Availability: |
| |||
JavaScript syntax: | NES | myLock = Lock | ||
NES | myLock = new Lock() | |||
Object properties: | constructor, prototype | |||
Object methods: | isValid(), lock(), unlock() |
In a server back end environment, you may have some objects which you share amongst several sessions. This means that they could be accessed on behalf of several clients all at once. You may want to prevent this happening by locking the object as the first client's request accesses it, and then unlocking it again as the request handler for that client no longer needs access to it.
You can create new Lock objects with the Lock() constructor.
It is good manners to unlock resources as soon as you can so that other processes can carry on running. You should not rely on the script exit handler unlocking the locks you place on objects.
Be careful when you use locks. It is possible to place mutually exclusive locks on objects and introduce a deadlocking situation. There is a potential for this if your script is locking more than one object and the locks are not correctly nested.
If you don't implement locks when necessary, you run the risk of run-time errors as your system can run out of resources.
See also: | Netscape Enterprise Server, unwatch(), watch() |
Property | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
constructor | 1.2 ![]() | ![]() | ![]() | ![]() | ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
prototype | 1.2 ![]() | ![]() | ![]() | ![]() | ![]() | 3.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
Prev | Home | Next |
locationbar | Up | Lock() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |