package singleton; public class ConnectionPool { private static ConnectionPool pool; private ConnectionPool() { } public static synchronized ConnectionPool getPool() { if (pool == null) { pool = new ConnectionPool(); } return pool; } }
package singleton; public class Application { public static void main(String[] args) { System.out.println(ConnectionPool.getPool()); } }