[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Locking objects



On Mon, 22 May 2000, alain Bedu wrote:
> >%_Hi,
> 
> I'm now trying to put locks on objects using DefaultLock class.
> First, is it the right classe to use ?

No, definitely not. There is no way to explicitely lock an object via an API
call. Lock and DefaultLock are in the core package so they are not part of the
API. Client code should never need to use classes from the core package (or
other non-API packages) directly.

Currently the only way to obtain WRITE locks is to mark a method of the object
as 'update' method. This can be done via the source code of the interface
('/*update/* comments) or via an ozone class descriptor (*.ocd file). When such
a method is executed ozone implicitely aquires the locks.


Falko

> 
> Then, I want to see what happens when 2 transactions want to lock the same object with LEVEL_WRITE or LEVEL_UPGRADE.
> (I suppose it's impossible, perhaps I'm wrong....)
> I create 2 threads, first one access and locks the object for 10 seconds while the second one try to access and lock the same object.
> I don't understand why I can't succeed, the second one can obtain the lock even if another transaction has already locked the object.
> 
> If anyone can explain me how to put explicitly locks or show me some code.....
> 
> thanks.
> 
> alain
> 

----------------------------------------
Content-Type: text/html; name="unnamed"
Content-Transfer-Encoding: quoted-printable
Content-Description: 
----------------------------------------

-- 
______________________________________________________________________
Falko Braeutigam                         mailto:falko@softwarebuero.de
softwarebuero m&b (SMB)                    http://www.softwarebuero.de