Instance counter

is there any other to get an instance counter besides telling it the number of instances in each class? here is one of my class, how could i add it and what would i have to put in my show class?
public class Cowboys extends Football {
public int scrimmage () {return passing+rushing+other;}
public void describe (){
     System.out.println(
          "Total yards the Cowboys gained this week is " +(passing+rushing+other) );
public static int counter = 1;
public class Show {........
     public static void main(String argv[]){
          Cowboys c=new Cowboys();
          c.describe();
                                   "The number of class instances in the Cowboys class is ");
          System.out.println(Cowboys.counter); class is ");
}

where am i supposed to plug this into, is it the
Cowboys or in the Show? i tried both and i keep
getting <identifier> expected in the line private static classCounter;.Something smells bad in the original code you posted. It looks like you have a bunch of code floating about that isn't in either class. That is wrong.

Similar Messages

  • REST API: Create Deployment throwing error BadRequest (The specified configuration settings for Settings are invalid. Verify that the service configuration file is a valid XML file, and that role instance counts are specified as positive integers.)

    Hi All,
    We are trying to access the Create Deployment method stated below
    http://msdn.microsoft.com/en-us/library/windowsazure/ee460813
    We have uploaded the Package in the blob and browsing the configuration file. We have checked trying to upload manually the package and config file in Azure portal and its working
    fine.
    Below is the code we have written for creating deployment where "AzureEcoystemCloudService" is our cloud service name where we want to deploy our package. I have also highlighted the XML creation
    part.
    byte[] bytes =
    new byte[fupldConfig.PostedFile.ContentLength + 1];
                fupldConfig.PostedFile.InputStream.Read(bytes, 0, bytes.Length);
    string a = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
    string base64ConfigurationFile = a.ToBase64();
    X509Certificate2 certificate =
    CertificateUtility.GetStoreCertificate(ConfigurationManager.AppSettings["thumbprint"].ToString());
    HostedService.CreateNewDeployment(certificate,
    ConfigurationManager.AppSettings["SubscriptionId"].ToString(),
    "2012-03-01", "AzureEcoystemCloudService", Infosys.AzureEcosystem.Entities.Enums.DeploymentSlot.staging,
    "AzureEcoystemDeployment",
    "http://shubhendustorage.blob.core.windows.net/shubhendustorage/Infosys.AzureEcoystem.Web.cspkg",
    "AzureEcoystemDeployment", base64ConfigurationFile,
    true, false);   
    <summary>
    /// </summary>
    /// <param name="certificate"></param>
    /// <param name="subscriptionId"></param>
    /// <param name="version"></param>
    /// <param name="serviceName"></param>
    /// <param name="deploymentSlot"></param>
    /// <param name="name"></param>
    /// <param name="packageUrl"></param>
    /// <param name="label"></param>
    /// <param name="base64Configuration"></param>
    /// <param name="startDeployment"></param>
    /// <param name="treatWarningsAsError"></param>
    public static
    void CreateNewDeployment(X509Certificate2 certificate,
    string subscriptionId,
    string version, string serviceName, Infosys.AzureEcosystem.Entities.Enums.DeploymentSlot deploymentSlot,
    string name, string packageUrl,
    string label, string base64Configuration,
    bool startDeployment, bool treatWarningsAsError)
    Uri uri = new
    Uri(String.Format(Constants.CreateDeploymentUrlTemplate, subscriptionId, serviceName, deploymentSlot.ToString()));
    XNamespace wa = Constants.xmlNamespace;
    XDocument requestBody =
    new XDocument();
    String base64ConfigurationFile = base64Configuration;
    String base64Label = label.ToBase64();
    XElement xName = new
    XElement(wa + "Name", name);
    XElement xPackageUrl =
    new XElement(wa +
    "PackageUrl", packageUrl);
    XElement xLabel = new
    XElement(wa + "Label", base64Label);
    XElement xConfiguration =
    new XElement(wa +
    "Configuration", base64ConfigurationFile);
    XElement xStartDeployment =
    new XElement(wa +
    "StartDeployment", startDeployment.ToString().ToLower());
    XElement xTreatWarningsAsError =
    new XElement(wa +
    "TreatWarningsAsError", treatWarningsAsError.ToString().ToLower());
    XElement createDeployment =
    new XElement(wa +
    "CreateDeployment");
                createDeployment.Add(xName);
                createDeployment.Add(xPackageUrl);
                createDeployment.Add(xLabel);
                createDeployment.Add(xConfiguration);
                createDeployment.Add(xStartDeployment);
                createDeployment.Add(xTreatWarningsAsError);
                requestBody.Add(createDeployment);
                requestBody.Declaration =
    new XDeclaration("1.0",
    "UTF-8", "no");
    XDocument responseBody;
    RestApiUtility.InvokeRequest(
                    uri, Infosys.AzureEcosystem.Entities.Enums.RequestMethod.POST.ToString(),
    HttpStatusCode.Accepted, requestBody, certificate, version,
    out responseBody);
    <summary>
    /// A helper function to invoke a Service Management REST API operation.
    /// Throws an ApplicationException on unexpected status code results.
    /// </summary>
    /// <param name="uri">The URI of the operation to invoke using a web request.</param>
    /// <param name="method">The method of the web request, GET, PUT, POST, or DELETE.</param>
    /// <param name="expectedCode">The expected status code.</param>
    /// <param name="requestBody">The XML body to send with the web request. Use null to send no request body.</param>
    /// <param name="responseBody">The XML body returned by the request, if any.</param>
    /// <returns>The requestId returned by the operation.</returns>
    public static
    string InvokeRequest(
    Uri uri,
    string method,
    HttpStatusCode expectedCode,
    XDocument requestBody,
    X509Certificate2 certificate,
    string version,
    out XDocument responseBody)
                responseBody =
    null;
    string requestId = String.Empty;
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
                request.Method = method;
                request.Headers.Add("x-ms-Version", version);
                request.ClientCertificates.Add(certificate);
                request.ContentType =
    "application/xml";
    if (requestBody != null)
    using (Stream requestStream = request.GetRequestStream())
    using (StreamWriter streamWriter =
    new StreamWriter(
                            requestStream, System.Text.UTF8Encoding.UTF8))
                            requestBody.Save(streamWriter,
    SaveOptions.DisableFormatting);
    HttpWebResponse response;
    HttpStatusCode statusCode =
    HttpStatusCode.Unused;
    try
    response = (HttpWebResponse)request.GetResponse();
    catch (WebException ex)
    // GetResponse throws a WebException for 4XX and 5XX status codes
                    response = (HttpWebResponse)ex.Response;
    try
                    statusCode = response.StatusCode;
    if (response.ContentLength > 0)
    using (XmlReader reader =
    XmlReader.Create(response.GetResponseStream()))
                            responseBody =
    XDocument.Load(reader);
    if (response.Headers !=
    null)
                        requestId = response.Headers["x-ms-request-id"];
    finally
                    response.Close();
    if (!statusCode.Equals(expectedCode))
    throw new
    ApplicationException(string.Format(
    "Call to {0} returned an error:{1}Status Code: {2} ({3}):{1}{4}",
                        uri.ToString(),
    Environment.NewLine,
                        (int)statusCode,
                        statusCode,
                        responseBody.ToString(SaveOptions.OmitDuplicateNamespaces)));
    return requestId;
    But every time we are getting the below error from the line
     response = (HttpWebResponse)request.GetResponse();
    <Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <Code>BadRequest</Code>
      <Message>The specified configuration settings for Settings are invalid. Verify that the service configuration file is a valid XML file, and that role instance counts are specified as positive integers.</Message>
    </Error>
     Any help is appreciated.
    Thanks,
    Shubhendu

    Please find the request XML I have found it in debug mode
    <CreateDeployment xmlns="http://schemas.microsoft.com/windowsazure">
      <Name>742d0a5e-2a5d-4bd0-b4ac-dc9fa0d69610</Name>
      <PackageUrl>http://shubhendustorage.blob.core.windows.net/shubhendustorage/WindowsAzure1.cspkg</PackageUrl>
      <Label>QXp1cmVFY295c3RlbURlcGxveW1lbnQ=</Label>
      <Configuration>77u/PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0NCiAgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KDQogIFRoaXMgZmlsZSB3YXMgZ2VuZXJhdGVkIGJ5IGEgdG9vbCBmcm9tIHRoZSBwcm9qZWN0IGZpbGU6IFNlcnZpY2VDb25maWd1cmF0aW9uLkNsb3VkLmNzY2ZnDQoNCiAgQ2hhbmdlcyB0byB0aGlzIGZpbGUgbWF5IGNhdXNlIGluY29ycmVjdCBiZWhhdmlvciBhbmQgd2lsbCBiZSBsb3N0IGlmIHRoZSBmaWxlIGlzIHJlZ2VuZXJhdGVkLg0KDQogICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCi0tPg0KPFNlcnZpY2VDb25maWd1cmF0aW9uIHNlcnZpY2VOYW1lPSJXaW5kb3dzQXp1cmUxIiB4bWxucz0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9TZXJ2aWNlSG9zdGluZy8yMDA4LzEwL1NlcnZpY2VDb25maWd1cmF0aW9uIiBvc0ZhbWlseT0iMSIgb3NWZXJzaW9uPSIqIiBzY2hlbWFWZXJzaW9uPSIyMDEyLTA1LjEuNyI+DQogIDxSb2xlIG5hbWU9IldlYlJvbGUxIj4NCiAgICA8SW5zdGFuY2VzIGNvdW50PSIyIiAvPg0KICAgIDxDb25maWd1cmF0aW9uU2V0dGluZ3M+DQogICAgICA8U2V0dGluZyBuYW1lPSJNaWNyb3NvZnQuV2luZG93c0F6dXJlLlBsdWdpbnMuRGlhZ25vc3RpY3MuQ29ubmVjdGlvblN0cmluZyIgdmFsdWU9IkRlZmF1bHRFbmRwb2ludHNQcm90b2NvbD1odHRwcztBY2NvdW50TmFtZT1zaHViaGVuZHVzdG9yYWdlO0FjY291bnRLZXk9WHIzZ3o2aUxFSkdMRHJBd1dTV3VIaUt3UklXbkFrYWo0MkFEcU5saGRKTTJwUnhnSzl4TWZEcTQ1ZHI3aDJXWUYvYUxObENnZ0FiZnhONWVBZ2lTWGc9PSIgLz4NCiAgICA8L0NvbmZpZ3VyYXRpb25TZXR0aW5ncz4NCiAgPC9Sb2xlPg0KPC9TZXJ2aWNlQ29uZmlndXJhdGlvbj4=</Configuration>
      <StartDeployment>true</StartDeployment>
      <TreatWarningsAsError>false</TreatWarningsAsError>
    </CreateDeployment>
    Shubhendu G

  • Automatically display instance count in caption of text field

    What is the code I use to make the caption of a text field show the instance count of its parent subform?

    There is nothing wrong with your code....but you are assigning a numeric value to a string value and javascript does not seem to like that. If you modify the right side of the equation to be:
    "" + this.parent.index
    Then it seems to work.
    Paul

  • Unable to install adobe reader-message :unable to unlock instance count... Please advise. Thx

    unable to install adobe reader-message :unable to unlock instance count... Please advise. Thx

    What is your operating system & version?
    Can you try downloading the installer from http://get.adobe.com/reader/direct/ or http://get.adobe.com/reader/enterprise/ ?

  • [BO XI 3.0] view document instances count is wrong

    If a user does not have the "View document instances" right and there are schedules set up for a particular report to go to other users then the count showing in InfoView is not zero, it counts all the recurring and successful instances even though that user cannot see them!
    I can't see this mentioned in fixed issues manuals for FP1, FP2 or FP3, and I can't find a fixed issues manual for BO XI 3.1
    What we want to happen is when a report is scheduled back to default destination ( i.e. public folders ) then we give the users the "View document instances" right and then the instances count would alert them to click the "view latest instance" option rather than just double clicking as they used to do in V5.1.9, but given that it counts other users schedules as well then that does not seem to be much use to alert users
    I know there is a global option to "open latest instance" but that fails because if there is not a latest instance then it does nothing when you double click
    anybody got any ideas about this?
    regards
    Andrew Dale

    tech support have logged an enhancement request for this for me

  • Quota still exceeded even after increasing instance count

    I have a personal website on a Shared plan, and while doing some development, I reached the memory quota (512 MB/hour). As I've done other times when this happens, I go to the scale page and increase the instance count to 2, which increases the memory quota
    to 1024 MB/hour.
    My dashboard shows all quota usage in the green, specifically memory usage at 513.2 MB/ 1024 MB. However, my site is still suspended for exceeding usage quota.
    Anyone have this experience or can explain what's going on?

    Hi,
     Hope your Website is up and running now. Azure will Restart the website at the beginning of the next quota interval.
     If you site is still down, I would suggest you contact support and have it looked at by an azure support engineer, since the issue may be at the backend.
     Regards,
     Nithin Rathnakar

  • Inheritable instance counter variable

    Here's a problem that's been bugging me for a while, and i'm sure there's a simple solution to it that is just escaping me.
    I'm developing a pluggable module based system, so i have my base class module with a reference counter counter += 1 in the constructor
    My problem is that subclasses of this module don't inherite their own counters (as in counters of the instances of that particular module), instead they just increment the base class's counter.
    public abstract class Module {
        //... other stuff
        public static long instanceCount = 0;
        /** Creates a new instance of Module */
        public Module() {
            init();
        public void uninit(){
            Module.instanceCount -= 1;
        public void init(){
            Module.instanceCount += 1;
        //... more stuff
    public class TestModule extends Module {
        //... more stuff
        public TestModule() {
            MenuItem = "Test/TestModule";
            ModuleID = "TESTMODULE";
        //... more stuff
    public class TestModule1 extends Module {
        //... more stuff
        public TestModule1() {
            MenuItem = "Test/TestModule1";
            ModuleID = "TESTMODULE1";
        //... more stuff
    }so, say i created 4 TestModules and 2 TestModule1s
    I'm trying to get something like:
    Module.instanceCount will equal 6
    TestModule.instanceCount == 4
    TestModule1.instanceCount == 2
    thanks
    -Mythagel

    Here is an idea. Use the following class to keep track of instances of specific classes:
    public class InstanceCounter {
      private static final Integer ONE = new Integer(1);
      private final Map counts = new HashMap();
      public void registerInstance(Class clazz) {
        final Integer oc = (Integer)counts.get(clazz);
        counts.put(clazz, oc == null ? ONE : new Integer(oc.intValue() + 1));
      public int getInstanceCount(Class clazz) {
        final Integer oc = (Integer)counts.get(clazz);
        return oc == null ? 0 : oc.intValue();
    }You can then change your Module class to this:
    public class Module {
      static final InstanceCounter instanceCount = new InstanceCounter();
      public Module() {
        instanceCount.registerInstance(getClass());

  • Limit Discoverer Desktop Instance Count and Run Time

    Hi all,
    I want to learn how I can restrict the number of Dicoverer desktop instances a user can open. I want to learn how to do it especially on Applications user basis because I will restrict only some of them. And also I want to know if it is possible to make a specific report to be able to be run only at given hours by given users.
    To be more explaining here is my case; we have a report that takes too long to complete takes too much CPU and memory. We have shops that will start using Discoverer Desktop and the report in question. Now our users are not too careful to and open too many Discoverer instances, I want to restrict this to 1 for the shop users. Also, I want them to run that report only after 6:00 pm because it is when the center office which has 80% of the Oracle users is empty.
    Is this possible, if it is could you tell me how to achieve it?
    Thanks in advance.
    Burak

    Hi,
    You need to establish whether the problem is with the pc, the network or the database. So the first things you need to check are:
    1. Is it a crosstab report, do you have the same issue if it is a table report?
    2. How many rows does it return, do you have the same issue if you limit the rows to just a few?
    3. Is it an Apps mode database mode EUL, if it is apps mode, you need to check the the users context in the database is not causing an issue?
    4. Is this a general problem or a problem with a specific query?
    Rod West

  • How can we calculate no. of instances in a java program ?

    Hi,
    I want to know that
    How can we calculate no. of instances in a java program ?
    Actually I just want to calculate number of live instances in a program at any time...
    Thanx in Advance
    Vijay

    Been asked a few times in this forum.
    Try having a search.
    One way, in brief, is to instrument your classes so that constructors update a per-type counter, and enqueue a PhantomReference for the instance.
    When you pop from an associated ReferenceQueue, decrement the counter for the no longer reachable type.
    Once you have this, you can query instance counts per type, or globably etc.
    We maintain a model which can be remotely queried - and display results over time using JGraph. Gives a fairly non-intrusive way to spot and narrow down the cause of memory leaks in a large application.

  • No Basic - Small instances of app service / web sites available in Europe North?

    Hi!
    I am trying to scale a website up from Shared to Basic/Small. I keep getting:
    "Not enough available reserved instance servers to satisfy this request. Currently 0 instances are available. If you are changing instance size you can reserve up to 0 instances at this moment. If you are increasing instance count then you can add extra
    0 instances at this moment."
    I can however set it up as Medium or Large both in the Basic and Standard tiers.
    Is this a known issue? Will it be adressed? In that case, when?
    Thank you!
    -Inge

    Inge,
    Please try again. The capacity should have been adjusted by now. In case you still hit an error, please provide a site name. Or if you do not want to provide a site name, please try to ping it and just copy paste the output here. E.g. (in this example the
    site name is "test"):
    ping test.azurewebsites.net
    Pinging waws-prod-am2-005.cloudapp.net [137.117.225.87] with 32 bytes of data:
    The underlined part is what I need to have to check.
    Thanks,
    Petr

  • Too many bean instances

    Hi
    We've been struggling with this issue for a while and were wondering
    if anyone has had similar exp's. reading this group and other weblogic
    ones I see that entity bean instance counts have been(sic) causing
    problems however we are having similar problems with stateless session
    beans.
    Here is our pool tag
    <pool>
    <max-beans-in-free-pool>2</max-beans-in-free-pool>
    <initial-beans-in-free-pool>1</initial-beans-in-free-pool>
    </pool>
    Now, when the server starts JProbe is reporting anything up to 30
    instances of EJB implementation Objects on the heap when we expect to
    see at most 2.
    This situation arises when the profiler invokes weblogic with no heap
    switches.
    if we use -ms64m -mx64m then we get even more instances on the heap.
    If we set the switches to -ms128m -mx256m then the counts are up in
    the hundreds and JProbe/weblogic takes as long as 30 minutes to start
    up.
    We are running the software on Win2000 with an 800Mhz intel processor
    running in 512 MB RAM.
    We have tried to get this working on Solaris8 but the server fell over
    after 2.5 hours having consumed 600 MB of virtual memory.
    Has any one suffered the same problem.
    Also are we alone in experiencing these huge delays when starting the
    server via the profiler.
    Oh yes, if we start the server 'standalone' it comes up in about 1
    minute.
    Any help greatly appreciated
    Cheers
    Duncan L strang

    Did you take a thread dump to see what the server was doing? I would start
    there ... hopefully it is a bug in your code (those are easy to get a fix
    for ;-)
    Peace,
    Cameron Purdy
    Tangosol Inc.
    Tangosol Coherence: Clustered Coherent Cache for J2EE
    Information at http://www.tangosol.com/
    "Duncan L" <[email protected]> wrote in message
    news:[email protected]..
    Hi
    We've been struggling with this issue for a while and were wondering
    if anyone has had similar exp's. reading this group and other weblogic
    ones I see that entity bean instance counts have been(sic) causing
    problems however we are having similar problems with stateless session
    beans.
    Here is our pool tag
    <pool>
    <max-beans-in-free-pool>2</max-beans-in-free-pool>
    <initial-beans-in-free-pool>1</initial-beans-in-free-pool>
    </pool>
    Now, when the server starts JProbe is reporting anything up to 30
    instances of EJB implementation Objects on the heap when we expect to
    see at most 2.
    This situation arises when the profiler invokes weblogic with no heap
    switches.
    if we use -ms64m -mx64m then we get even more instances on the heap.
    If we set the switches to -ms128m -mx256m then the counts are up in
    the hundreds and JProbe/weblogic takes as long as 30 minutes to start
    up.
    We are running the software on Win2000 with an 800Mhz intel processor
    running in 512 MB RAM.
    We have tried to get this working on Solaris8 but the server fell over
    after 2.5 hours having consumed 600 MB of virtual memory.
    Has any one suffered the same problem.
    Also are we alone in experiencing these huge delays when starting the
    server via the profiler.
    Oh yes, if we start the server 'standalone' it comes up in about 1
    minute.
    Any help greatly appreciated
    Cheers
    Duncan L strang

  • To find the Biztalk Active and Dehydrated instances using powershell script

    Hi,
    Has anyone has the power shell script to finf the number of active and dehydrated instances in Biztalk?

    Hi Sujith,
    Following Powershell script would get you the count of Active and Dehydrated instances:
    $a=Get-WmiObject -Class "MSBTS_ServiceInstance" -Namespace 'root\MicrosoftBizTalkServer' | Where-Object { $_.Item -match "$Name" -and $_.Item -ne "" -and ($_.ServiceStatus -eq "1" -or $_.ServiceStatus -eq "2" -or $_.ServiceStatus -eq "8" ) } | measure
    $a.Count
    Here ServiceStatus values for
    "Active" instance is 2 and “Dehydrated”instances is
    8 (and 1 for "Ready to Run" which might help you since you're interested in active instance count)
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • GetInstancesByFilter returns no instance

    Hi,
    I've a random comportment with BusinessProcess.getInstancesByFilter. Some times, this methods returns no instance although there is instances corresponding to my filter.
    Here my code :
    Fuego.Papi.BusinessProcess bp;
    Fuego.Papi.InstanceFilter instF;
    Fuego.Instance[] instances;
    bp = BusinessProcess();
    try {
    for (int i=0;i<100;i++) {
         bp.connectTo(url : Fuego.Server.directoryURL, user : "admin", password : "password",process : "/Process1");
         // création du filtre
         instF = InstanceFilter();
         instF.create(processService : bp.processService);
         instF.addAttributeTo(variable : "prjDemande", comparator : Comparison.IS,
         value : (String)i);
         // récupération de l'instance
         instF.searchScope = SearchScope(participantScope : ParticipantScope.ALL, statusScope : StatusScope.ONLY_INPROCESS);
         instances = bp.getInstancesByFilter(filter : instF);
         if (instances.count() == 0) {
         logMessage("============> Pas d'instance trouvée pour "+i);
         // Récupération de l'instance
         foreach (instance in instances) {
         logMessage("=============> instance "+i+" trouvée : "+activite+" / "+demande);
         bp.disconnectFrom();
    finally {
    try{
    bp.disconnectFrom();
    The only solution, I've found is to loop on the getInstancesByFilter until it returns a result...
    Thanks you for you help
    Thierry

    Is it running on Enterprise. If it's Enterprise are you running on a J2EE container (WLS)? How do you have your Workspace configured (single, multiple)?

  • Why is there a maximum of 10 instances on azure websites?

    Why is there a hard maximum of 10 instances on azure websites?
    Will it be possible to scale to more than 10 in the future.

    Hi,
    At currently, the limit of the azure website instance count was 10, as the support said, this was by design, I suggest you submit this as new feature at:
    http://feedback.azure.com/forums/34192--general-feedback
    Best Regards
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Determine if Instance of Class exists?

    Hello out there :)
    could anyone tell me if there is a way to determine if an instance of a specific class exists.
    btw my class design does not allow me to use static variables for instance counter or somehting - i am trying to prevent this.
    here is my situation:
    I have a class in which's constructor i would like to check if an instance of an inherited class exists - of THE inheritet class, that this constructor was called from (i could pass this information via constructor)
    and now i only want the constructor to proceed, if there is no instance of this class yet.
    thx to everyone who can help me :)

    mlk wrote:
    Imagist wrote:
    Let's see, your root class would be:
    public class ClassXY
         private static boolean instanceExists = false;
         public ClassXY() { instanceExists = true; }
         final public static boolean instanceExists() { return instanceExists; }
    When a object gets GC'ed, should that still return exists? :)Ah! You're right! So the code would be:
    public class ClassXY
         private static boolean instanceCount = 0;
         public ClassXY() { instanceCount++; }
         final public static boolean instanceExists() { return instanceCount > 0; }
         protected void finalize() { instanceCount--; }
    }There might be a threading issue with that, too; it's been a while since I dealt with finalization.
    One question for the original poster: do you want the constructor to fail if an instance already exists? If that's the case, the code above can be simplified further.

Maybe you are looking for

  • How can I update a quicktime movie placed in Keynote, that has been modified outside of Keynote??

    HI! I really like Keynote for quicktime playback during a tv/film shoot, and use it frequently on set. Media assets change frequently though, and it would be nice if the movies I place would update along with the external source. How can this happen

  • Message mapping with dynamic node

    Hi, I am doing message mapping where my source structure is <root>      <EmpCount>2</EmpCount>      <Emp>           <item>                <code>1</code>                <name>ABC</name>           </item>                                  <item>        

  • STKO and STPO link

    Hi, How to find the link STLAL(Alternative BOM) field in STKO and STPO. Please let me know how to link. Its very urgent. Thanks & Regards, Murali.

  • MDX Function Descendants

    Hey, I'm trying to use a mdx function on the business model using Evaluate_AGGR. Any idea why this is not working? EVALUATE_AGGR('Descendants( \[%1], 1, AFTER)', "ES_FIN_BGATE_BIRE"."BGATE".."Pnl"."Gen6,SITES" ) I've got the following error: Syntax e

  • Unacceptable levels of service

    What is going on with BT?, for weeks now I have experienced connection issues along with many others it seems by reading these forums.  I have tried everything possible with my hardware/PC and yet the problem persists, this is not an issue my end.  H