• Post Reply Bookmark Topic Watch Topic
  • New Topic

Object Locking mechanism  RSS feed

 
shiva kore
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I want to implement new locking mechanism similar to like how threads locking or synchronized does the operation. Any inputs to implement out own locking mechanism ?


With regards,
Shiva kore
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want to do this? And how would it be different from the existing locking mechanisms?
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You write your own virtual machine; if it is different from that in the Java Language Specification you cannot call the language Java.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A different JVM is not necessary, as it is perfectly possible to write locking mechanisms using the classes provided by the JRE. Whether that is possible in the case shiva is thinking about, we'll know once the questions I asked have been answered.
 
shiva kore
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf,

Thanks, You are right. I am a beginner to java coding just thinking is it possible to write our own locking technique or not.

Thanks,
Shiva kore
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shiva kore wrote:
I am a beginner to java coding just thinking is it possible to write our own locking technique or not.


Well, wouldn't that really depend on what you are trying to do? If you want to have some code that does some sort of locking, then take a look at the classes in the java.util.concurrent package. There are lots of different types of synchronization mechanisms there -- perhaps you can add to it, or use them as the basis for your own locking mechanism.

If you are trying to modify the synchronize keyword to do something else (ie. change the Java language structure), as other has stated, it will probably be a bit too much for a beginner...

Henry
 
shiva kore
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Henry, I will go through java.util.concurrent package and let me try..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!