– notes, snippet codes, and my journal

“pessimistic locking” and “optimistic locking.”

leave a comment »

Pessimistic Locking :
Pessimistic locking is when a transaction occurs, and then the resource is locked from the time it is first accessed. Until the transaction finished another transaction cant accessed the resources.

Optimistic Locking :
Optimistic locking applied a fail safe way. The state of resource is locked as soon the transaction occurs. But when another transaction occurs and attempting to accessed the resource it will result a delayed. Until the first accessed resources finished and unlock the resources.
The lock exists until the transaction committed or rolled back. If the resource is released. It will be compare the state which has been changed to the state when the time its locked. If the state differ it will rolled back the resource.

It compare the state of resource instead compare the changed data.
Some article defined a state as a version.


Written by snippetjournal

September 29, 2012 at 2:02 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: