so I have problem with last requirement I have made this task with this task done but without 4,5 requirement done by using:
public synchronized static IMF getFund() {
but I have to make synchronized field so I made it and I think that this should work the same :
public static IMF getFund() {
synchronized(imf){
if (imf == null)
{
imf = new IMF(); }
return imf;
}}
but it doesn't and here is my question why ?
package pl.codegym.task.task17.task1707;
/*
IMF
*/
public class Solution {
public static void main(String[] args) {
IMF fund = IMF.getFund();
IMF anotherFund = IMF.getFund();
System.out.println(fund == anotherFund);
}
}