bean 싱글톤1 [Spring] Bean을 싱글톤으로 사용해도 되는 이유 package singletoneTest; public class Object1 { private static Object1 o; // 싱글톤 private static int oNumber; // 상태 저장 public static Object1 getInstance(){ if(o == null) o = new Object1(); return o; } public int func(int n){ try { Thread.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } return n; } public int sfunc(int n){ oNumber = n; try { Thread.sleep(1); } catch (InterruptedE.. 2022. 7. 18. 이전 1 다음