The synchronized keyword significantly slows a program, so remove unnecessary synchronized statements in methods.
Superfluous synchronization
- 9
Locked
Comments (6)
- Popular
- New
- Old
You must be signed in to leave a comment
Justin Smith
27 September 2021, 01:51
This is kind of a weird task because you don't have to know what any of the code does (there's even a sneaky "do something here..." that you can ignore completely). All you have to do is follow the conditions to the letter.
+1
Angel Stefan
30 January 2022, 15:15
This task have no sense at all for me, at least not now. All i did it was to follow the Requirements.
+2
Олег БайбулаExpert
4 February, 05:24
I think this was made to teach a student to remember the place of synchronised keyword in the signature.
0
Ewerton Backend Developer
3 July 2019, 18:14
Why shouldn't this part be synchronized:
What if some thread put a value in s, while another just checked it as a null string? 0
Sela
3 August 2020, 03:58
CharSequence always is a String therefore this method is an infinite loop calling itself recursively in second if block and modifies nothing especially not a shared resources.
even if third if statement was somehow reached then CharSequence would never be a Solution because it neither implements this interface nor extends other class which implements it.
other words boolean expression of third if
always falls to false. +1
DarthGizka
6 June 2021, 11:25
In addition to what Sela said, the only object accesses in this function are delegating calls; there is never a situation where multiple accesses occur in sequence (and hence might require synchronisation).
0