Question
Answer below questions regarding the Singleton pattern: (3 points) Singleton can initialize the class in two different approaches; eager initialization, lazy initialization, a) what is
Answer below questions regarding the Singleton pattern:
-
(3 points) Singleton can initialize the class in two different approaches; eager initialization, lazy initialization, a) what is the difference between them in terms of the following: when initialization happen, resource usage, and whether it is thread safe or not .
-
(5 points) Suppose that you have class called CDRomDriver and you want to make that that there is only one instance of this class. Write code for this class that manages the one instance using the lazy initialization and make sure that this instance is thread-safe
-
(2 points) Write code to show how class TestDrive can get an instance from CDRomDriver
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started