• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

[ NO PASS!!! ] - What happen???

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all...
today I retrieve my result... the follow the Assessor_1 report:

This report shows the total points that could have been awarded in each section, and the actual number of points you were awarded.
This is provided to give you per-section feedback on your strengths.
The maximum possible score is 400; the minimum to pass is 320.
General Considerations (maximum = 100): 100
Documentation (maximum = 70): 70
O-O Design (maximum = 30): 30
GUI (maximum = 40): 24 ----> I DON'T UNDERSTAND, BUT POSSIBLE
Locking (maximum = 80): 0 -----> WHAT!!! IT'S NOT TRUE!!! (see belowe)
Data store (maximum = 40): 40
Network server (maximum = 40): 40
Major point loss for record-locking mechanism, which is not according to spec.
Your locking code does not block when trying to lock a locked record. It just throws an exception.

I TEST THIS FUNCTIONALITY... WHEN LOCK A LOCKED RECORD AN EXCEPTION IS THOWS ! ! ! I DON'T UDERSTAND...



Laura
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Laura,

Sorry to hear that you didn't pass

When you try to lock a locked record, you should certainly not throw an exception. But your thread should give up cpu and start waiting for the record to be unlocked again. So you would have something like:

in your lock-method:


in your unlock-method:


and then you could have following sample application:
a) thread1: lock(1); // locks record 1
b) thread2: lock(1); // thread2 has to wait until thread1 unlocks record 1
c) thread1: update(1, newData); // record 1 is updated with newData and thread2 still consumes no CPU and is in waiting state
d) thread1: unlock(1); // thread1 unlocks record 1 and so all waiting threads are notified (by notifyAll call)
e) thread2: continues where it lefts its execution, so checks if record 1 is locked and record is not locked, so thread2 has locked record 1 and can continue (and in your application thread2 never continued its execution because you throwed an exception in step b).

I hope explanation helps you understanding what you did wrong, so you could correct your assignment and re-submit it. The wait/notifyAll mechanism is just 1 of the possible solutions to take care of this record locking (which i used). If you have andrew's book, just take a very close look to the threading chapter.

Kind regards,
Roel
 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Laura,

It sounds as though you haven't implemented the locking method correctly, the requirement is wait until the record is unlocked, however it sounds like you are throwing an expection is the record is alreay locked, which might explain why you lost points for locking.

// Locks a record so that it can only be updated or deleted by this client.
// If the specified record is already locked, the current thread gives up
// the CPU and consumes no CPU cycles until the record is unlocked
.



Regards,
Jason
 
Laura Pecoraro
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Roel De Nijs
thanks very much for your help (and example)... I thinks that I'am very stupid... the Sun specification say
the current thread gives up the CPU and consumes no CPU cycles until the record is unlocked... So, I understand than consumes no CPU cycles to mean NO WAIT CPU, therefore, I throws an exception when try to lock a record locked... and using your esample, the thread2 when try to lock(recNo:2) really throws Exception....

Thanks Laura

 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Laura,

If a thread is waiting, it is not consuming any cpu cycles. It's just waiting "on a bench" for (in this case) a record being unlocked. When then the notifyAll is called, the thread goes from that bench to the pool with runnable threads. And then a scheduler picks out 1 thread from this pool and that thread will run and consume a CPU cycle.
You can find here an overview about the different states of a thread.

So when a record is already locked by another thread (t1), the thread (t2) just has to wait until the record becomes available (when t1 unlocks the record). When t2 is notified, t2 tries to get the lock on that record (but maybe there are also a bunch other threads t3, t4, t5,... trying to acquire the lock on that record, so 1 thread will get the lock and the other threads will go back to waiting state) and then continue with the update or delete. In your solution an exception is thrown and the update or delete of t2 will never happen (because the exception is thrown).
I know it's one of the hardest (and most important) parts of the assignment and that's clearly visible in the per-section scores: 80 points is the highest per-section score (except for the 100 on general considerations).

Kind regards,
Roel
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy, Laura.

First, I am extremely sorry to hear that you didn't pass. Indeed, you are not supposed to throw an exception; this way, the locking mechanism wouldn't have much sense. And the explanation provided by Roel explains pretty well the locking process.

In the name of the JavaRanch SCJD forum, I'd like to let you know that we'll do everything we can to help you passing this certification. And by the way, please do not give up. I am 100% sure that, if you fix this problem, you'll pass with a very good grade. Let's be positive and go for it!
 
Laura Pecoraro
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roberto Perillo wrote:Howdy, Laura.

First, I am extremely sorry to hear that you didn't pass. Indeed, you are not supposed to throw an exception; this way, the locking mechanism wouldn't have much sense. And the explanation provided by Roel explains pretty well the locking process.

In the name of the JavaRanch SCJD forum, I'd like to let you know that we'll do everything we can to help you passing this certification. And by the way, please do not give up. I am 100% sure that, if you fix this problem, you'll pass with a very good grade. Let's be positive and go for it!



Hi Roberto,
thanks about your support

I try to fix my code, and try again exam... but I'am very angry becouse a don't pass for an incomprehension... so I got the max score about all section except for GIU (24 ) and LOCK (0 )....

Laura



 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Laura, sorry to hear you didn't pass. For locking, Roel has described the logic behind it already. To test it, you may want to use Roberto's Data class test here. Highly recommended.

For your GUI, I'm sure you can improve that too. I got 39/40 for my GUI, maybe you can have a look at my SCJD comments (from my signature).

The most important thing is locking for SCJD. If you can't get it to work "properly" (eg don't deadlock, don't throw exception, GUI don't hang) then you are good. Good luck
 
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Laura,

Sorry about your bad result I second the idea to use Roberto's test class. I used his as well as a couple other ones. I struggled with this concept, too, due to lack of experience. I understand it pretty well now, after using the test classes and reading about Locking/Unlocking (over and over). You will probably get deadlocks in the beginning, but keep at it, and your code will pass the test. Then you can submit, and YOU will pass the SCJD!
 
Laura Pecoraro
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all for support and consolation

Hi Laura

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So when something like this happens what's next? to buy the resubmission assignment or what ?
 
Ranch Hand
Posts: 80
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Owhh Laura... i am really sorry about that!!

It could be happens with everyone... don't worry Ok?

Cherrs!!!
Julio
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulises Pulido wrote:So when something like this happens what's next? to buy the resubmission assignment or what ?



It's not necessary to take the essay exam again. She just needs to fix the locking part now, resubmit the project, and very very soon she'll be a SCJD.
 
Laura Pecoraro
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulises Pulido wrote:So when something like this happens what's next? to buy the resubmission assignment or what ?



Hi Pulido...
I can not answer yet ... I'm waiting for a response from the Sun

I plan to pay the submission test again

Hi Laura
 
Ulises Pulido
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hope Laura will be a SCJD soon =)
 
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are there any news ?

Jeffry Kristianto Yanuar SCJP, SCJA, SCJD
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, Laura passed with a great score: 98% on 17th July.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic