Why is the runFinalizersOnExit method in class System depricated?

The explaination given in javadocs for deprication of runFinalizersOnExit in System class is that "It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects, resulting in erratic behavior or deadlock". But the finalizers are supposed to be called only when the Java runtime exits. The confusion I have is once the java runtime exits we should not have any live objects hence the aboue case should not arise or have i missed some details. Please help.

The finalize method goes off when garbage collection happens, and this doesn't always happen when the program ends. Finalize methods are not well supported in Java since they are not always called (or they get called while the program is still running). Sun should come up with a better plan on the finalize method and so they are executed when the program ends. This isn't what finalizeOnExit does, despite the name.

Similar Messages

  • Why is the static method in the superclass more specific?

    Why is the static method in the superclass more specific than the static method in the subclass? After all, int is a subtype of long, but Base is not a subtype of Sub.
    class Base {
        static void m(int i){ System.out.println("Base"); }
    class Sub extends Base {
        static void m(long l){ System.out.println("Sub"); }
    class Test {
        public static void main(String[] args) {
            int i = 10;
            Sub sub = new Sub();
            sub.m(i);
    }The first example compiles without error.
    Output: Base
    class Base {
        void m(int i){ System.out.println("Base"); }
    class Sub extends Base {
        void m(long l){ System.out.println("Sub"); }
    class Test {
        public static void main(String[] args) {
            int i = 10;
            Sub sub = new Sub();
            sub.m(i);
    }In the second example, both instance methods are applicable and accessible (JLS 15.12.2.1), but neither is more specific (JLS 12.2.2), so we get a compiler error as expected.
    : reference to m is ambiguous,
    both method m(int) in Base and method m(long) in Sub match
    sub.m(i);
    ^
    1 error
    Why don�t we get a compiler error for the static methods?

    Thank you for your ideas.
    ====
    OUNOS:
    I don't get Sylvia's response. This is about static methods, what are instances are needed for??Yes, the question is about static methods. I included the example with non-static methods for a comparison. According to JLS 15.12.2, both examples should cause a compiler error.
    And why you create a Sub object to call the method, and dont just call "Sub.m(..)"Yes, it would make more sense to call Sub.m(i). Let�s change it. Now, I ask the same question. Why is there no compiler error?
    ====
    DANPERKINS:
    The error in your logic stems from calling static methods on instances, as ounos pointed out. Solution: don't. You won't see any more ambiguities.A static member of a class may also be accessed via a reference to an object of that class. It is not an error. (The value of the reference can even be null.)
    Originally I was looking only at the case with non-static methods. Therefore, I used sub.m(i). Once I understood that case, I added the static modifiers. When posting my question, I wish I had also changed sub.m to Sub.m. Either way, according to JLS 15.12.2, a compiler error should occur due to ambiguous method invocation.
    ====
    SILVIAE:
    The question was not about finding an alternative approach that doesn't throw up an ambiguity. The question related to why, in the particular situations described, the ambiguity arises in only one of them.
    Yes.
    Proposing an alternative approach doesn't address the question.
    Yes.
    ====
    If anyone is really interested, here is some background to the question. Some people studying for a Sun Java certificate were investigating some subtleties of method invocations:
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=24&t=019182
    I remember seeing the non-static case discussed in this forum once before in a more practical context. jschell probably knows the link.

  • Why does the Java method ServletContext.getResourceAsStream return null with a know good path to an xsl file?

    iPLANET ISSUE
    Why does the Java method ServletContext.getResourceAsStream return null with a know good path to an xsl file?
    CODE
    ServletContext context = mpiCfg.getServletConfig().getServletContext();
    // Debugging
    out.print(context.getServerInfo());     // Get server info
    out.print(“getRealPath = ” + context.getRealPath("WEB-INF/xsl/RedirectToAcs.xsl"));
    String strXslName = "RedirectToAcs.xsl";
    InputStream is = context.getResourceAsStream("WEB-INF/xsl/"+ strXslName);
    TRACE FROM THE LOG
    [26/Jul/2002:08:23:15] info ( 2868): [0][][ClearCommerceCcpaMpi][]getServerInfo() = iPlanet-WebServer-Enterprise/6.0, getRealPath() = C:\iPlanet\Servers\web-apps\ccpa\WEB-INF\xsl\RedirectToAcs.xsl
    [26/Jul/2002:08:23:15] info ( 2868): [0][][ClearCommerceCcpaMpi][]strXslName = RedirectToAcs.xsl, is = null
    [26/Jul/2002:08:23:15] info ( 2868): [1][][ClearCommerceCcpaMpi][16]ResourceAsStream is null
    [26/Jul/2002:08:23:15] info ( 2868): [1][][ClearCommerceCcpaMpi][30]Problem reading XSL file.
    DIRECTORY DUMP
    C:\iPlanet\Servers\web-apps\ccpa\WEB-INF\xsl>dir
    Volume in drive C has no label.
    Volume Serial Number is 9457-EBF4
    Directory of C:\iPlanet\Servers\web-apps\ccpa\WEB-INF\xsl
    07/22/2002 05:54p <DIR> .
    07/22/2002 05:54p <DIR> ..
    07/22/2002 05:54p 3,086 RedirectToAcs.xsl
    07/22/2002 05:54p 3,088 Response.xsl
    2 File(s) 6,174 bytes
    2 Dir(s) 1,797,405,696 bytes free

    I think there's supposed to be a forward slash before WEB-INF.
    InputStream is = context.getResourceAsStream("/WEB-INF/xsl/"+ strXslName);

  • Why is the installer stuck on "Checking System Profile-"?

    I'm trying to install Flash Catalyst Beta on a MacBook Pro running OS 10.6.1 (Snow Leopard).
    The installer starts to work, but then it stops at the point where it checks the system profile (see attached screenshot). It doesn't seem to have crashed as the dock icon allows me to quit without force quitting the application.
    I've tried it in my regular user account and the administrator account, but the behaviour is identical.
    Any help would be appreciated.

    I appreciate all your efforts, but I¹ve just received my new copy of CS5, so
    I¹ll be installing the final version.
    G
    From: ritesh kapoor <[email protected]>
    Reply-To: <[email protected]>
    Date: Thu, 29 Apr 2010 04:32:06 -0600
    To: Gary Horsman <[email protected]>
    Subject: Why is the installer stuck on "Checking System
    Profile…"?
    Thanks Gary.
    I need to ask you a few questions and request you to perform some more steps
    so that I can debug your problem.
    1. Have you modified any folder permissions, authorization setup using
    Keychain Access utility (or any other tool)?
    2. Open a Terminal window, and run the command 'ls -l /tmp' and copy-paste
    the output printed on your screen in your reply.
    3. Delete all files whose name start with 'asu' in your /tmp folder. Run the
    command 'rm -rf /tmp/asu*'. Restart your machine.
    4. Launch the Flash Catalyst setup and check if installation proceeds
    successfully. If it doesn't, proceed to the step below.
    5. Open the folder containing the Flash Catalyst setup. Browse to the
    'packages' folder and rename the file 'install.sig' to 'update.sig'. Double
    click and launch the Flash Catalyst setup. This will not install the
    application but install the Adobe Application Manager. Let me know if you
    see a small dialog with a progress bar. Rename back update.sig to
    install.sig. Update us your observations. Continue to next step.
    6. Launch 'Disk Utility' app (from /Applications/Utilities). Select your OS
    partition in the left panel and click on 'First Aid' tab on the top. Click
    on the 'Repair Disk Permissions' button at the bottom.
    7. Again, launch the Flash Catalyst setup and check if installation proceeds
    successfully. If it doesn't, proceed to the step below.
    8. Open a Terminal window and navigate to the directory containing the Flash
    Catalyst setup. Run the command 'sudo Install.app/Contents/MacOS/Install'
    and enter the password. Let me know if the installer launches and on
    following the screen instructions do you still see the error screen or does
    the installation proceed successfully.

  • Smart forms - Identifying the calling method and class

    Hi Experts,
    Is there a way to identify the method and class names that called a smart form..
    Any inputs or pointers in this regard woul;d be of great help.
    Regards,
    Kris.

    Hi Kartik,
    The procedure you suggested is good to identify the class by manual intervention.
    But I need the class/mehtod name in the program as the logic of the code depends on which class called the smart form.
    Any idea how this can be read?
    Regards,
    Kris.

  • Why is the mouse not active in system preferences?

    When attempting to configure a blue tooth mouse, something happened to the wired mouse. I went to system preferences, click on mouse and got no response. Also the original colnfiguration (I'm left handed and switched buttons) appeared. The mouse works out of system preferences, but the buttons are erratic. I did a (1)reset with a simple power off using the button on the back; no change; (2) after powering off again, I upplugged the iMac for AC and removed all periperals from the computer. Then powered up again; no change. Am not willing to continue without some advice from the experts. My protection plan has expired.

    Sounds weird. Have you repaired the disk permissions? Maybe USB-ports have wrong permissions in /dev.
    As you cannot use mouse, open Terminal (Command - Space, type in Terminal, Enter) and type command:
    diskutil repairPermissions /

  • Why is the icloud icon not in system preferences on my Macbook Pro?

    My Macbook does not have the icon for icloud in system preferences. I have the newest softeware and do not know how to set up icloud for m device if it is not listed under system preferences. Any help would be appreciated.

    Mac ox 10.6.8 is the operating system so I guess it wont be in my preferences. Thanks. So I have an icloud account and email address so will my new iPhone, ipod and computer not all be in the icloud?

  • HT2534 WHY IS THE PAYMENT METHOD: NONE GONE?

    I keep getting "security code invalid" and people are telling me to change the payment method to "NONE"
    its no longer an option is ios5?

    I have the same problem i can't even get free apps or anything

  • Get the current method's class

    I need to get the Method object representing the method I'm executing. How can I get this in an easy way? (I use J2SE 1.4.2)
    It looks like I must do something like this
    public String methodName(Object obj1, Object obj2) {
    this.getClass().getMethod("methodName", new Class[] {obj1.getClass(), obj2.getClass()});
    }

    The getMethod() of Class will return the method. Below is the syntax for that
    public Method getMethod(String name,
                            Class[] parameterTypes)

  • What's the deal with Lazy Class Loading?

    My understanding was that if class B is used in class A, (i.e. imported and used in local code), but class A does NOT
    - extend class B
    - implement class B
    - have a field of class B's type or
    - use class B in any of its methods signatures
    then class B would not be loaded unless the localised code that uses it was executed.
    However, I am of course finding that this is not the case.
    So what's the deal?
    Why are my classes being loaded when there's no code that uses them?

    Okay, prepare for some gory details...
    My actual code is slightly more complicated than A & B, but the context of the error is the same.
    Here is what's happening:
    The main method, in class A is creating an instance of A;
    The constructor of A creates an instance of B;
    The constructor of B calls a static method in C;
    The static method in C creates an instance of C.
    C contains an instance method M that creates an instance of inner class C.C1, however method M is NOT called from C's constructor, nor will it EVER be called in the (test) application.
    Class C.C1 implements interface D.D1.
    Neither of classes D or D.D1 are in the classpath (intentionally).
    A NoClassDefFoundError is thrown, indicating that D.D1 could not be loaded, with the top method on the stack trace being (from memory) B.<init> (i.e. no mention of C, the only class that refers to D or D.D1).
    My assumption was that C.C1 should never be loaded, because it is never used, or that, if it was loaded eagerly, no exception should be thrown until a point at which it is used.
    Seeing as the inner classes and the inheritance can complicate things above, I commented out the code that uses C.C1 and D.D1, which results in the following sequence of events (which still fail):
    The main method, in class A is creating an instance of A;
    The constructor of A creates an instance of B;
    The constructor of B calls a static method in C;
    The static method in C creates an instance of C.
    Difference is here:
    C contains an instance method M that creates an instance of class D, however method M is NOT called from C's constructor, nor will it EVER be called in the (test) application.
    Class D does not appear in any method signatures or as a field type.
    Class D is not in the classpath (intentionally).
    A NoClassDefFoundError is thrown, indicating that D could not be loaded, with the top method on the stack trace being B.<init> (i.e. no mention of C, the only class that refers to D).
    Again, my assumption is that D should never be loaded, because the only method that uses it is never called.
    Why is the JVM attempting to load D and telling me that it can't find it when the application never actually uses D?
    Crazy stuff!

  • What's the safest way to reload system software

    What's the safest method to reload system software on an intel iMac? My wife's iMac has been behaving erratically.  I have run hardware and virus scans and found no issues. Virus software is Saphos and up to date. Problems began after a brief (5 second) power failure in the neighborhood. My Mac Pro seems fine. Both were on and connected to the internet at the time. I've run a full backup on the iMac so all important files are protected. What next?

    Also, your system may have been slow because you installed antivirus software.
    DO NOT reinstall Sophos Antivirus.
    OS X has it's own built-in software tools to help in detecting or blocking of potential malware.
    Some anti-virus solutions can slow down your Mac, but to be honest, the best anit-virus is you, the user and your brain.
    Don't visit questionable websites or website you are unsure about.
    Don't install pirated software or software downloaded from a questionable or unknown websites or sources.
    Java is a vulnerability right now, if you do not need it, don't use it.
    Use a browser filter and pop-up blocker
    Don't open email attachments from email addresses that you do not recognize.
    Install security updates when they become available
    Educate yourself as to what threats are common and active.
    In effect, use your brain as the AV filter.
    Follow that advice and in MOST cases, you will be fine and won't feel the need to have to install antivirus software.

  • Quick tutorial of using methods of class

    Hi,
    I have never use methods of class before. Is there anyone can give me a quick tutorial how to do it?
    To be more specific – I need convert field 'DAUER' into the required format using one of the following methods of class 'CL_HR_T510_PSRCL':
    •     CONVERT_DURATION_TO_MMMM: Duration Conversion to Format 'MMMM'
    •     CONVERT_DURATION_TO_MMMM: Duration Conversion to Format 'YYMM'
    Please be more detailed in describing it.
    Your help will greatly appreciate.
    Thanks,
    Veb

    Hello Veb,
    You will find at this sdn page at section ABAP Objects , documentations and links about ABAP OO :
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/35eaef9c-0b01-0010-dd8b-e3b0f9ed7ccb#section7 [original link is broken]
    For your example :
    1) You can use like this :
    CALL METHOD CL_HR_T510_PSRCL=>CONVERT_DURATION_TO_MMMM
      EXPORTING
        DURATION = old_duration
      RECEIVING
        MMMM     = new_duration.
    1) Like this :
    l_dauer = convert_duration_to_mmmm(
                                 duration = l_dauer).
    Best regards

  • Comparing 2 HashMap with the equals method

    Hi,
    I�m trying to compare 2 HashMap with the equls method like this:
    saveAnyWayMap.equals(keysMap)
    The 2 HashMaps contains the following values and keys:
    saveAnyWayMap: {P_PERSON.PA_TIDPKT=null, P_PERSON.P_PXXX92=xxx, P_PERSON.P_P
    XXX91=xx, P_PERSON.P_PXXX90=xxx}
    keysMap: {P_PERSON.PA_TIDPKT=null, P_PERSON.P_PXXX92=xxx, P_PERSON.P_PXXX91=
    xx, P_PERSON.P_PXXX90=xxx}
    Why dose the equals method return false?
    When P_PERSON.PA_TIDPKT is not null the equals method returns true. Can�t the values be null if you want to compare HashMaps or what is wrong?
    Can someone please help?
    Thanks!
    /Lisa

    Works fine when I use null objects in a hashmap. Are you sure it is the null values that gives you the problem? And is the key in both maps?
    What if the only key-value pair you have is P_PERSON.PA_TIDPKT and null?
    Do you use string objects as keys?

  • Redefined methods in class

    hi exprets!!
    i am working in chaning in a class methods. i was given with a class and need to change only in redefined methods. can you please help me how to recognise the redefined methods in class and how to recognize the redefined  methods from other methods.
    plz help me on the same.
    thank you,
    Mahesh

    In a class, all inherited methods are show in 'display' format and the characters are shown in blue (highlighted). You can't change the name of the method, change parameters or whatever. All other methods are shown in 'edit' mode. Now for all methods inherited from superclass(es) only the redefined methods are shown in 'black' characters in stead of blue. These methods are the ones that are redefined. If you double click on the non-redefined methods, you get a pop-up message, saying that this method is implemented in superclass 'XXX'. For the redefined methods, this will not be the case.

  • How can I kill all Threads of the same class from within the run() method?

    Ok
    I have a class called Consumer that extends Thread
    I have several Consumer threans running... but, when a certain condition is true (within the run() method) in ANY of the threads, I want to kill ALL the threads of that object.
    is this possible?

    I know this is gonna be too demanding, but can someone please tell me why my Consumer's run() method never reaches the System.out.println( "ALL CONSUMING DONE") line
    Create a multi-threaded prime number calculator that is based on the producer-consumer model
    using semaphores. Your program should be able to check for prime numbers in a range specified
    by the user and with a variable number of threads. Example:
    $ java PrimeFind 3 5000 10000
    should use 1 producer and 2 consumers (3 threads in total, obviously the minimum is 2) to find all
    the prime numbers in the range [5000,10000].
    The producer should: use a buffer to store candidate numbers that have to be checked for
    primality.
    Consumers should: read from the buffer, check if a number is prime and update the status of the
    program accordingly (e.g. show the number on the screen, or save it to a file)
    import java.util.concurrent.Semaphore;
    import java.io.*;
    public class Assign1 {
    static int fromThisNumber;
    static int toThisNumber;
    static int numberOfThreads;
    static int buffer[];
    static Semaphore ready;          /*This semaphore is used by the Producer to signal
                                         an "OK" to the consumers*/
    static Semaphore critical;  /*This is a Mutex semaphore. It allows only 1 consumer
                                         to enter his critical section.
    static Semaphore counter;     /*This semaphore acts as a counter.
                                        Instead of having a global variable
                                         incremented each time, we just release()
                                         this semephore when we find a prime number
                                         Because remember that release() increments permits
    static Producer prod;
    static Consumer cons[];
    static int in=0;
    static int out=0;
    static PrintWriter outFile;
         public static void main (String args[]){
              try{
                   outFile=new PrintWriter(new FileWriter("primes.txt"));
                   }catch(Exception e){}
              numberOfThreads=Integer.parseInt(args[0]);
              fromThisNumber=Integer.parseInt(args[1]);
              toThisNumber=Integer.parseInt(args[2]);
              buffer=new int[Integer.parseInt(args[2])-Integer.parseInt(args[1])+1];
              ready=new Semaphore(0,false); /*We initialise it to 0 because we wait
                                                      for the Producer to produce atleast a
                                                      item. Suppose ready was 1 and if
                                                      Consumer ran first he would be in an
                                                      empty buffer */
              critical=new Semaphore (1,false);/*We initialise it to 1 because when
                                                         the first Consumer thread tries
                                                         to enter its critical section, it
                                                         should be allowed to;
                                                         Subsequent threads will have to
                                                         wait since only 1 thread can
                                                         access its critical section at a time*/
              counter=new Semaphore(0,false); // duh!
              cons=new Consumer[numberOfThreads-1]; /*numberOfThreads-1 because 1 thread
                                                                is taken by the Producer*/
              //Creating Producer object
              prod=new Producer();
              //Creating the Consumer object and start the thread.
              for(int i=0;i<cons.length;i++)
                        cons=new Consumer();
                        cons[i].start();
              prod.start();          
              //Printing to screen and file
    /*          for(int i=0;i<buffer.length;i++)
                   if(buffer[i]!=0)
                             System.out.println(buffer[i]);
                             outFile.println(buffer[i]);
              System.out.println("Total primes found between "+args[1]+" and "+toThisNumber+": "+counter.availablePermits()+"\n primes.txt written");
              outFile.println("Total primes found between "+args[1]+" and "+toThisNumber+": "+counter.availablePermits());
              outFile.close();*/                    
    static class Producer extends Thread {
         public void run(){try{
              while(in<buffer.length)     /*'in' should always be more than 'out'.Oherwise the consumer will try to access an empty index*/
                   {     System.out.println("producing");     
                        buffer[in]=fromThisNumber;
                        in++;
                        fromThisNumber++;
                        ready.release();
              catch (Exception e){e.printStackTrace();}
              System.out.println("ALL PRODUCING DONE");
    static class Consumer extends Thread {
         int tempout=0;
         public void run(){try{
              System.out.println("before while"+this.getId());
              while(tempout<=in)
                   System.out.println("before ready"+this.getId()+" "+ready.availablePermits()+" "+in);
                   ready.acquire();
                   System.out.println("before critical.acquire"+this.getId());
                   critical.acquire();
                   tempout=out;
                   out++;
                   critical.release();               
                   if(!isPrime(buffer[tempout]))
                        {System.out.println(buffer[tempout]+" by "+this.getId());buffer[tempout]=0;}
                   else {counter.release();System.out.println("prime added: "+buffer[tempout]+" by "+this.getId());}
                   critical.acquire();
                   tempout=out;
                   System.out.println("tempout:"+tempout+" of "+this.getId());
                   critical.release();
              System.out.println("ALL CONSUMING DONE"+this.getId());
         catch(Exception e){e.printStackTrace();}
         //Prime number-checking method     
         public boolean isPrime(int n){
              for(int i=2;i<=(n/2);i++)
                   if(n%i==0)
                        return false;
              return true;
    ======================
    import java.util.concurrent.Semaphore;
    import java.io.*;
    /* 3 questions to ask Barlas
    * Why error if I start the Consumer threads before Producer
    * Why does the counter semaphore always give a +1 result at the end
    * Is there a way I can verify that all the work is not being done by only 1 consumer thread? In other words, the workload is being shared properly
    * if I put ready.acquire() outside or inside the while loop, its not making any difference, why?
    * Strangely, its not making any difference if I playing with the release() and aquire() of the semaphores, WHY?!?!
    public class Assign1 {
    static int fromThisNumber;
    static int toThisNumber;
    static int numberOfThreads;
    static int buffer[];
    static Semaphore ready;          /*This semaphore is used by the Producer to signal
                                       an "OK" to the consumers*/
    static Semaphore critical; /*This is a Mutex semaphore. It allows only 1 consumer
                                       to enter his critical section.
    static Semaphore counter;     /*This semaphore acts as a counter.
                                  Instead of having a global variable
                                       incremented each time, we just release()
                                       this semephore when we find a prime number
                                       Because remember that release() increments permits
    static Producer prod;
    static Consumer cons[];
    static int in=0;
    static int out=0;
    static PrintWriter outFile;
         public static void main (String args[]){
              try{
                   outFile=new PrintWriter(new FileWriter("primes.txt"));
                   }catch(Exception e){}
              numberOfThreads=Integer.parseInt(args[0]);
              fromThisNumber=Integer.parseInt(args[1]);
              toThisNumber=Integer.parseInt(args[2]);
              buffer=new int[Integer.parseInt(args[2])-Integer.parseInt(args[1])+1];
              ready=new Semaphore(0,false); /*We initialise it to 0 because we wait
                                                      for the Producer to produce atleast a
                                                      item. Suppose ready was 1 and if
                                                      Consumer ran first he would be in an
                                                      empty buffer */
              critical=new Semaphore (1,false);/*We initialise it to 1 because when
                                                      the first Consumer thread tries
                                                      to enter its critical section, it
                                                      should be allowed to;
                                                      Subsequent threads will have to
                                                      wait since only 1 thread can
                                                      access its critical section at a time*/
              counter=new Semaphore(0,false); // duh!
              cons=new Consumer[numberOfThreads-1]; /*numberOfThreads-1 because 1 thread
                                                                is taken by the Producer*/
              //Creating Producer object
              prod=new Producer();
              //Creating the Consumer object and start the thread.
              for(int i=0;i<cons.length;i++)
                        cons[i]=new Consumer();
                        cons[i].start();
              prod.start();          
              //Printing to screen and file
    /*          for(int i=0;i<buffer.length;i++)
                   if(buffer[i]!=0)
                             System.out.println(buffer[i]);
                             outFile.println(buffer[i]);
              System.out.println("Total primes found between "+args[1]+" and "+toThisNumber+": "+counter.availablePermits()+"\n primes.txt written");
              outFile.println("Total primes found between "+args[1]+" and "+toThisNumber+": "+counter.availablePermits());
              outFile.close();*/                    
    static class Producer extends Thread {
         public void run(){try{
              while(in<buffer.length)     /*'in' should always be more than 'out'.Oherwise the consumer will try to access an empty index*/
                   {     System.out.println("producing");     
                        buffer[in]=fromThisNumber;
                        in++;
                        fromThisNumber++;
                        ready.release();
              catch (Exception e){e.printStackTrace();}
              System.out.println("ALL PRODUCING DONE");
    static class Consumer extends Thread {
         int tempout=0;
         public void run(){try{
              System.out.println("before while"+this.getId());
              while(tempout<=in)
                   System.out.println("before ready"+this.getId()+" "+ready.availablePermits()+" "+in);
                   ready.acquire();
                   System.out.println("before critical.acquire"+this.getId());
                   critical.acquire();
                   tempout=out;
                   out++;
                   critical.release();               
                   if(!isPrime(buffer[tempout]))
                        {System.out.println(buffer[tempout]+" by "+this.getId());buffer[tempout]=0;}
                   else {counter.release();System.out.println("prime added: "+buffer[tempout]+" by "+this.getId());}
                   critical.acquire();
                   tempout=out;
                   System.out.println("tempout:"+tempout+" of "+this.getId());
                   critical.release();
              System.out.println("ALL CONSUMING DONE"+this.getId());
         catch(Exception e){e.printStackTrace();}
         //Prime number-checking method     
         public boolean isPrime(int n){
              for(int i=2;i<=(n/2);i++)
                   if(n%i==0)
                        return false;
              return true;
    ===========================
    BTW, when I tried to change extends Thread to implements Runnable I got some kinda of error.
    Actually, my program is pretty complete... its just that something if messed up in my Consumer's run() method's while loop... I think
    I know guys its crazy to ask ya'll to look at so much code, but.... I'd really appreciate it. This assignment is killing me, been at it since 10 hours now....

Maybe you are looking for

  • Registering an ipod touch that went 1 month without backup?

    Daughter got brand new ipod for 13th bday. I set it up for her on her brand new email and brand new apple ID. and opted out of icloud and registering at first. She went to town on wifi, lots of apps, took pictures, created artwork, loves her ipod for

  • TV output and music artwork

    Using the av cable can u view artwork from your music on the TV? Mandla

  • How to handle Excise Invoice

    Dear All, My problem is regarding excise invoice. Yesterday we have recieved the excise invoice of Month August 2007. Now my problem is how to handle this excise invoice because everything has been posted in Auguset 2007. Now we want to pay excise am

  • Can I update installed BPEL 10.1.2 with BPEL 10.1.2.0.2?

    Hi, at last, it is finally out! But questions are coming up: Do I have to uninstall my running and configured BPEL 10.1.2? Or does the 10.1.2.0.2 installer update my current release and configuration is preserved? Thanks, Torsten

  • Spot color used in indesign document

    Hi all, How to find spot color used (text, frame and any othe item) in Indesign document. Please help me to write javascript code. thanks, mon