I don't see what other objects than "this" could be used here. I tried current Thread it also failed. I don't see in the previous solutions a clue (but I might have missed it) and after research on internet I only find "this" or a specific object already created like an instance with is created using a field in the class etc. But I don't find anything related on the exercice where there are no explicitly created objects of Solution.
Can someone give me a hint?
EDIT: the "new object" was just one of my many attempts on IntelliJ
package com.codegym.task.task26.task2608;
/*
A wise man thinks once before speaking twice
*/
public class Solution {
int var1;
int var2;
int var3;
int var4;
public Solution(int var1, int var2, int var3, int var4) {
this.var1 = var1;
this.var2 = var2;
this.var3 = var3;
this.var4 = var4;
}
public int getSumOfVar1AndVar2() {
synchronized (new Object()) {
return var1 + var2;
}
}
public int getSumOfVar3AndVar4() {
synchronized (new Object()) {
return var3 + var4;
}
}
public static void main(String[] args) {
}
}