SlideShare a Scribd company logo
Create a simple
singleton java class
* Creating a singleton java class in an application is also needed. There are a lot of objects
that only need a single instance that’s why it is called Singleton.
* Some example is when you are creating an object driver in connecting to an API. From my
experience, i created a single instance of a connection going to an API because the server
can’t handle multiple request or else the server of the host will fall. Even though you can
create a multiple instance so that transaction will be processed asynchronously.
* the first example is the class is initialized as static.
* the class also created a private constructor so no other
object or class can create an instance of this class.
* the class also created a private constructor so no other
object or class can create an instance of this class.
* also we used the word synchronized so that this will fit in a multithreaded
environment.
* one cons for this implementation is that this may affect the perfomarnce
of the application
* one cons for this implementation is that this may affect the perfomarnce
of the application
* we can also used this technique by checking first if there is
an instance of the class then that is the time we could do
synchronized. this might help now with the performance.
* I can say it is important that you also know how to write a singleton
class so that you will know when you can used this singleton classes.
This is important so you can managed the classes running in your
application without having deep usage of the memory
References:
* www.google.com
* www.javacodegeeks.com
THE END

More Related Content

PPTX
React mini lecture
PPTX
Selenium_For_Beginners_VodQA_Final
PDF
MVVM & RxSwift
PPT
Selenium
PPTX
Build Tools-Introduction (3)
PDF
MVVM on iOS
PDF
How Mozilla uses Selenium
PPTX
UI Testing Automation - Alex Kalinovsky - CreamTec LLC
React mini lecture
Selenium_For_Beginners_VodQA_Final
MVVM & RxSwift
Selenium
Build Tools-Introduction (3)
MVVM on iOS
How Mozilla uses Selenium
UI Testing Automation - Alex Kalinovsky - CreamTec LLC

What's hot (20)

PPT
Agile Software Development by Sencha
PPT
HTML5 Multithreading
PPTX
How to make your functional tests really quick
PPTX
ODP
Introduction to PhantomJS
PPT
No Va Taig April 7 2010
PDF
UI Testing Automation
PDF
Test your Javascript! v1.1
PPTX
Progressive Web App Testing With Cypress.io
PDF
AngularJS and Protractor
PPTX
Selenium drivers
PPTX
Better End-to-End Testing with Page Objects Model using Protractor
PDF
Building testable chrome extensions
DOCX
Protractor end-to-end testing framework for angular js
PPTX
Automation test
PDF
Making cross browser tests beautiful
PPTX
Web automation with Selenium for software engineers
PDF
03 ruby environment
PDF
Jquery react angular
PPTX
Heuristics to scale your framework
Agile Software Development by Sencha
HTML5 Multithreading
How to make your functional tests really quick
Introduction to PhantomJS
No Va Taig April 7 2010
UI Testing Automation
Test your Javascript! v1.1
Progressive Web App Testing With Cypress.io
AngularJS and Protractor
Selenium drivers
Better End-to-End Testing with Page Objects Model using Protractor
Building testable chrome extensions
Protractor end-to-end testing framework for angular js
Automation test
Making cross browser tests beautiful
Web automation with Selenium for software engineers
03 ruby environment
Jquery react angular
Heuristics to scale your framework
Ad

Similar to Simple Singleton Java (20)

PDF
20 most important java programming interview questions
PPTX
Java Basics
PPTX
Singleton Pattern (Sole Object with Global Access)
PPTX
The Singleton Pattern Presentation
PPS
Jump start to OOP, OOAD, and Design Pattern
PPT
Jump Start To Ooad And Design Patterns
PDF
A350103
PDF
Automation testing real time interview question.pdf
PPTX
Creating and destroying objects
PPTX
Javascript for the c# developer
PPT
Java Basics for selenium
PDF
Java Interview Questions
PDF
Android interview questions
PDF
Android interview questions
PDF
AliExpress’ Way to Microservices - microXchg 2017
PDF
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
ODP
Jquery Plugin
PDF
‏‏‏‏‏‏oop lecture 6_١٢٥٩٤٧taiz univercity.pdf
PPTX
Singleton Design Pattern - Creation Pattern
PDF
Creating a Whatsapp Clone - Part I - Transcript.pdf
20 most important java programming interview questions
Java Basics
Singleton Pattern (Sole Object with Global Access)
The Singleton Pattern Presentation
Jump start to OOP, OOAD, and Design Pattern
Jump Start To Ooad And Design Patterns
A350103
Automation testing real time interview question.pdf
Creating and destroying objects
Javascript for the c# developer
Java Basics for selenium
Java Interview Questions
Android interview questions
Android interview questions
AliExpress’ Way to Microservices - microXchg 2017
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
Jquery Plugin
‏‏‏‏‏‏oop lecture 6_١٢٥٩٤٧taiz univercity.pdf
Singleton Design Pattern - Creation Pattern
Creating a Whatsapp Clone - Part I - Transcript.pdf
Ad

More from Christian Hipolito (12)

PPT
Simple Poll in Mule
PPT
Used Java Component To Access Flow and Session Vars
PPT
Flowvar and Sessionvar in Mule
PPT
Simple Java component in Mule
PPT
Simple VM in Mule
PPT
Propertiesinmule
PPT
Jogging101
PPT
PPT
Agile coaching
PPT
Srum master
PPT
Simple http and jms for beginners
PPT
Agile Session
Simple Poll in Mule
Used Java Component To Access Flow and Session Vars
Flowvar and Sessionvar in Mule
Simple Java component in Mule
Simple VM in Mule
Propertiesinmule
Jogging101
Agile coaching
Srum master
Simple http and jms for beginners
Agile Session

Recently uploaded (20)

PPTX
L1 - Introduction to python Backend.pptx
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Nekopoi APK 2025 free lastest update
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Understanding Forklifts - TECH EHS Solution
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Introduction to Artificial Intelligence
PDF
AI in Product Development-omnex systems
PPTX
history of c programming in notes for students .pptx
L1 - Introduction to python Backend.pptx
Wondershare Filmora 15 Crack With Activation Key [2025
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Nekopoi APK 2025 free lastest update
Operating system designcfffgfgggggggvggggggggg
Upgrade and Innovation Strategies for SAP ERP Customers
Understanding Forklifts - TECH EHS Solution
How Creative Agencies Leverage Project Management Software.pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
How to Migrate SBCGlobal Email to Yahoo Easily
Design an Analysis of Algorithms I-SECS-1021-03
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Odoo POS Development Services by CandidRoot Solutions
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Design an Analysis of Algorithms II-SECS-1021-03
wealthsignaloriginal-com-DS-text-... (1).pdf
Introduction to Artificial Intelligence
AI in Product Development-omnex systems
history of c programming in notes for students .pptx

Simple Singleton Java

  • 2. * Creating a singleton java class in an application is also needed. There are a lot of objects that only need a single instance that’s why it is called Singleton. * Some example is when you are creating an object driver in connecting to an API. From my experience, i created a single instance of a connection going to an API because the server can’t handle multiple request or else the server of the host will fall. Even though you can create a multiple instance so that transaction will be processed asynchronously.
  • 3. * the first example is the class is initialized as static. * the class also created a private constructor so no other object or class can create an instance of this class. * the class also created a private constructor so no other object or class can create an instance of this class.
  • 4. * also we used the word synchronized so that this will fit in a multithreaded environment. * one cons for this implementation is that this may affect the perfomarnce of the application * one cons for this implementation is that this may affect the perfomarnce of the application
  • 5. * we can also used this technique by checking first if there is an instance of the class then that is the time we could do synchronized. this might help now with the performance.
  • 6. * I can say it is important that you also know how to write a singleton class so that you will know when you can used this singleton classes. This is important so you can managed the classes running in your application without having deep usage of the memory