Conversation
EagerLoading 클래스를 구현하여 Singleton을 사용해 객체 유일성을 보장합니다. 주요 변경사항: - 해당 인스턴스 클래스 사용되는 시점이 아니라 미리 생성됩니다. - 클래스가 메모리에 적재될 때 미리 생성되어 초기화가 완료되어 스레드 안정성을 보장합니다.
LazyLoading 클래스를 생성하여 Singleton을 보장합니다. 주요 변경사항: - LazyLoading은 EagerLoading 와 비교해서 인스턴스 초기화가 발생하기 전에는 객체가 생성하지 않습니다. - 인스턴스가 많은 리소스를 점유하거나 초기화가 오래 걸리는 경우에는 인스턴스를 미리 만들어 초기화하는 것은 리소스 낭비입니다. - 하지만 인스턴스가 많은 리소스를 차지하고 있다면 fail-fast 설계 원칙에 따라 프로그램 시작 전 인스턴스를 초기화가 완료되는 것이 합리적입니다.
DoubleCheckLocking 클래스를 생성하여 Singleton을 보장했습니다. 주요 변경사항: - 초기화 방식과 높은 동시성을 모두 지원하는 싱글턴 패턴 이중 잠금패턴을 적용했습니다. - 기존 즉시 초기화에 문제점을 해결하면서 동시성을 보장하는 패턴으로 두 가지 기능을 보장합니다. - CPU 명령이 재정렬되면 클래스의 객체가 instance 멤버 변수가 지정된 후, 초기화가 이루어지기 전에 다른 스레드에서 이 객체를 사용하려고 할 수 있다. - volatile 키워드를 인스턴스 멤버 변수에 추가로 명령어 재정렬을 방지하면 된다.
HolderIdiom 클래스를 생성하여 Singleton을 보장하였습니다. 주요 변경사항: - 이중 잠금보다 간단한 방식으로 Java 내부 클래스를 사용하는 방식입니다. - 인스턴스 유일성과 생성 프로세스의 스레드 안정성으로 JVM 의해 보장합니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EagerLoading 클래스를 구현하여 Singleton을 사용해 객체 유일성을 보장합니다.
주요 변경사항: