Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6154037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:11:38+00:00 2026-05-23T20:11:38+00:00

How many number of Instance can be there when same singleton class is packaged

  • 0

How many number of Instance can be there when same singleton class is packaged in two war file(and both war files are packaged in
one ear file)

Cas1

MyUnderstanding
As per my understanding for singleton class there will be a single instance per JVM. So as per this answer for above should be one instance
as there will be one instance of jvm for the ear file.

Case2

But on differnt sites(one at http://www.coderanch.com/t/520891/java/java/Singleton-Diff-WAR-files-same) , folks have also mentioned singleton produces
the single instance for a class loader. they said for two war files there will be two class loader . So ther will be two instance of singleton.

What is the right answer?

If second case is right can we say below statements

1)For singleton class there will be a single instance per classloader(here i mean classloader hirerchy in a jvm instance that includes bootstrap loader,
application class loader) not for jvm.

2)For two war files packaged in same ear file there will be two classloader hirerchies under same jvm instance

posted at http://forums.oracle.com/forums/thread.jspa?threadID=2253940&tstart=0 but not concrete answer

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:11:38+00:00Added an answer on May 23, 2026 at 8:11 pm

    1) If your class is in each WAR, then there will be an instance per webapp (classloader herarchy).

    2) Yes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How many max number of lines of code one .cs file should hold. Are
Is there any way to know how many times a instance of a class
On the dashboard, there are many charts that we can look at. Which one
Are there a finite number of questions that can be asked regarding a specific
how many number of thread per process default in the system.thread.threadpool in asp.net 3.5
In each table have many number of rows with amount. Like this i have
I need to find out how many times the number greater than or less
On my program icon i want to show how many show a number, like
I'm setting up a number sites right now and many of them have multiple
I've heard many people say that if the number of expected elements in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.