What is the best way in Java to create a singleton? Should a DB connection be a singleton (being a singleton it\'s automatically thread-safe)? Because theoretical the DB can
Singletons are a pattern - there's no explicit way to create one, you just follow the design practice.
So, if you're using a database that can handle concurrent reads/writes (i.e. MySQL), you don't need to worry so much about thread safety. If you're using a DB that's doesn't do concurrent writes well (SQLite), then a singleton should theoretically work.