• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Locking - 80 points?

 
Dennis Grimbergen
Ranch Hand
Posts: 159
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In the near future I will start working on my SCJD exam. In the meanwhile I'm just reading some stuff, for example here on coderanch. I have a question about locking. An simple way to do this is making the Data class a Singleton with synchronized methods, making sure that only one thread can access the Data class. But this can't be all? I mean, making a Singleton and adding the keyword 'synchronized' to the methods costs 5 minutes of work. How can this be worth 80 points?

Can someone clear this up for me?

Regards,
Dennis
 
Carlos Morillo
Ranch Hand
Posts: 221
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dennis,


You will also need to implement lock() and unlock() methods from the Sun provided interface that your Data class MUST implement.

They will be used for logical record locking, let's say in some client code you have:



or




HTH,


Carlos.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dennis,

With such a name you have to be a Belgian (beer)

Like Carlos already indicated: you have to make your Data class thread-safe, making it a singleton and marking all methods synchronized is just fine. But you also have the locking of records (before update/delete) as mentioned and excellently explained in the ScjdFaq.
And when you have an interface with the lockCookie it will be more easy than if you have an interface without lockCookie.

I spent 5 months developing this application (combining with a full time job) and it certainly isn't that easy as you think It was a learningful and challenging experience.

Kind regards,
Roel
 
Dennis Grimbergen
Ranch Hand
Posts: 159
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roel,

Although my name indicates to be a Belgian, I'm Dutch. I just love the Belgium beers

Thnx for your reply. I see I didn't read the ScjdFaq good enough. Five months sounds pretty much for a rather small Java SE application. But I know that it always costs more time than it looks... I'll come up with some more questions soon I think. Thnx for the replies guys.

Dennis
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dennis Grimbergen wrote:Five months sounds pretty much for a rather small Java SE application.

I'm convinced it can be done faster, but combining it with a full time job and a social life is hard (you don't have always the time and/or desire to develop). And I'm a perfectionist and that can be time consuming
 
Carlos Morillo
Ranch Hand
Posts: 221
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I totally agree with Roel, you don't always feel like working on it if you have a life,
plus if you do a couple of code reviews, make some changes, review your javadoc documentation,
choices.txt, end user documentation, etc. it takes time.

That's what I've been doing lately and I plan to request upload permissions 2-3 days before my deadline.


Best,


Carlos.
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, y'all.

I think not only the locking part is hard, but all the rest is hard too. Of course, we have been posting in this forum for quite some time now, and today, I could implement this project in 1 or 2 days. But I remember that back then, I had several doubts, and while designing the APIs, I always went back to change something... and today, I would have done it totally different. So, it won't be certainly only 5 minutes of effort; this certification is harder then it looks like.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roberto Perillo wrote:Of course, we have been posting in this forum for quite some time now, and today, I could implement this project in 1 or 2 days.

show-off
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


If only I had 2 days to work on the assignment...
 
Walid Abd Elsalam
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dennis Grimbergen wrote:Hi Roel,

Although my name indicates to be a Belgian, I'm Dutch. I just love the Belgium beers



Is it true that the Dutch and the Belgain don't get along very well
My Ex-GF was Belgain and she couldn't stand the Dutch.
 
Dennis Grimbergen
Ranch Hand
Posts: 159
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Uhh I have no idea...I live in the north of the Netherlands
I have no reason to dislike Belgians...I mean..their beer is good..and their 'Vlaamse frieten' also (fried potato's)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic