Ironing

  • 5
  • Locked
Back to the daily grind... Add one synchronized keyword to make diana and steve take turns ironing, since there's only one iron! Hint: Use class-level locking.
You can't complete this task, because you're not signed in.
Comments (10)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
DarthGizka
Level 24 , Wittenberg, Germany
6 June 2021, 11:40
task1718 (Ironing) CAVEAT: the last requirement is incompletely specified; the sentence should end in " on the Iron class". That is what the validator insists on. There are several classes that could be used with exactly equal effect; insisting that Iron specifically be used is utterly preposterous, given the overall 'quality' of the code.
Gellert Varga
Level 23 , Szekesfehervar, Hungary
18 June 2021, 14:54
I totally agree.
Gellert Varga
Level 23 , Szekesfehervar, Hungary
15 May 2021, 21:48
!!! All about synchronized (ClassName.class) topic and about this task: https://codegym.cc/help/15301
Chris J.
Level 18 , Arlington, United States
30 March 2021, 20:30
There has to be a better way to construct this lesson. There isn't a shared iron object... returning the iron creates a new iron.... the confusing way this is constructed distracts from the objective of the challenge.
Oliver Heintz
Level 18 , Mustang, United States
1 March 2021, 14:12
I still don't fully understand what it means by ****.class. I mean, when I see it used and I think about it, it makes sense, but it's not something I've given any real thought to as I don't remember ever having used it prior to this level.
Gellert Varga
Level 23 , Szekesfehervar, Hungary
17 May 2021, 19:36
https://codegym.cc/help/15301
John Squirrels Website Admin at CodeGym
18 May 2021, 10:59
We see it's already resolved.
Gellert Varga
Level 23 , Szekesfehervar, Hungary
18 May 2021, 18:52
Yes, and I pasted this link here because I could get a lot of useful information from it that might help others understand this task. Maybe it will help Oliver too if he will look at his letters one day in the future...:)
Sela
Level 20 , Poland
31 July 2020, 13:37
so static keyword guarantees that a class is instantiated only once during program run. however is it proper to drop the new keyword where it falls? i mean
new Iron()
Gellert Varga
Level 23 , Szekesfehervar, Hungary
17 May 2021, 20:02
"Static" means: Things marked with "static" (variable, method, class) belongs only to the class that contains them; and do not belong to objects created from that class. (In other words, static is not an instance variable.) In contrast, instance variables belong only to the created object. You can create any number of objects from a static class. But you can also put this static Iron class in a separate .java file, and then you shouldn’t have to call it static. If we're talking about a variable that is static, then this variable only needs to be loaded into memory once, the first time the class is used. (But maybe I just don't understand your question...)