How can I prevent class garbage collection????

Hi,
Is there a way to prevent a class from being garbage collected without using the -noclassgc option? Is there some code I can include in a class that tells the JVM not to garbage collect that particular class?
Thanks in advance,
Jacob.

The code shown below (slightly modified from yours) should work correctly on any 1.0.x throught 1.4 JVM.
Look at this article for further info: http://www.javaworld.com/javaworld/javatips/jw-javatip52.html
public class SQLManager extends PoolManager {
    private static SQLManager myself;
    //code.........................
    public static SQLManager getInstance() {
        // This version of a getInstance method suffers from the use of the
        // broken (unreliable) double checked locking idiom.  It should never
        // be used on a system with more than one processor and is ill-advised
        // any other time.  It can  lead to accesses to uninitialized objects.
        // See http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html
        // or http://c2.com/cgi/wiki?DoubleCheckedLockingIsBroken
        // So despite its common appearance in books and pattern repositories,
        // it should not be used.
        if (myself == null) {
            synchronized(SQLManager.class) {
                if (myself == null)
                    myself = new SQLManager();
        return myself;
    private SQLManager() {
        livethread();
        //code.........................
    void livethread()
        System.out.println("##############################################################");
        System.out.println("###################Live Thread called#########################");
        System.out.println("##############################################################");
        Thread thread = new Thread()
            public void run()
                // added this code to ensure that run() actually is getting
                // called
                System.out.println("##############################################################");
                System.out.println("#################### Thread Started ##########################");
                System.out.println("##############################################################");
                Class myClass = SQLManager.class;
                while (true)
                    try
                        synchronized (myClass)
                            myClass.wait();
                    catch (InterruptedException ex)
                        System.out.println("##############################################################");
                        System.out.println("###################Thread interrupted#########################");
                        System.out.println("##############################################################");
                    finally
                        System.out.println("##############################################################");
                        System.out.println("################### Something Happened #########################");
                        System.out.println("##############################################################");
                System.out.println("##############################################################");
                System.out.println("#################### Thread Dead?? ##########################");
                System.out.println("##############################################################");
        thread.setDaemon(true);
        System.out.println("##############################################################");
        System.out.println("#################### Starting Thread #########################");
        System.out.println("##############################################################");
        thread.start();
    //code.........................
}

Similar Messages

  • How can I prevent filter from getting applies to .html page?

    Hi,
    I have a MyFaces filter that I don't want applied to pages ending in ".html". However, upon visiting the "/myapp/index.html" page of my application, I get an internal server error, and the stack trace indicates that the filter is being invoked. How can I prevent such a filter from being applied to ".html" pages? The stack trace and the web.xml file are below.
    Thanks, - Dave
    Error I get when visiting index.html page
    ####<Oct 30, 2008 8:46:44 AM MDT> <Error> <HTTP> <rhonti> <nps-supp-gui-ms-1> <[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1225378004500> <BEA-101020> <[weblogic.servlet.internal.WebAppServletContext@4f2189 - appName: 'nps_history_gui', name: 'nps_history_gui.war', context-path: '/nps_history_gui'] Servlet failed with Exception
    java.lang.IllegalStateException: ExtensionsFilter not correctly configured. JSF mapping missing. JSF pages not covered. Please see: http://myfaces.apache.org/tomahawk/extensionsFilter.html
    at org.apache.myfaces.renderkit.html.util.AddResourceFactory.throwExtensionsFilterMissing(AddResourceFactory.java:389)
    at org.apache.myfaces.renderkit.html.util.AddResourceFactory.checkEnvironment(AddResourceFactory.java:349)
    at org.apache.myfaces.renderkit.html.util.AddResourceFactory.getInstance(AddResourceFactory.java:279)
    at org.apache.myfaces.webapp.filter.TomahawkFacesContextWrapper.<init>(TomahawkFacesContextWrapper.java:115)
    at org.apache.myfaces.webapp.filter.TomahawkFacesContextFactory.getFacesContext(TomahawkFacesContextFactory.java:85)
    at javax.faces.webapp.FacesServlet.prepareFacesContext(FacesServlet.java:307)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:141)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
    at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:525)
    at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:261)
    at com.myco.nps.im.plugin.NPSIMIntercepter.doFilter(NPSIMIntercepter.java:101)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at com.myco.nps_history.filters.NoCachingFilter.doFilter(NoCachingFilter.java:30)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3229)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2002)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1908)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1362)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    =================Begin web.xml=======================
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
    <display-name>
    nps_history_gui</display-name>
    <filter>
    <filter-name>extensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    <init-param>
    <description>Set the size limit for uploaded files.
    Format: 10 - 10 bytes
    10k - 10 KB
    10m - 10 MB
    1g - 1 GB</description>
    <param-name>uploadMaxFileSize</param-name>
    <param-value>100m</param-value>
    </init-param>
    <init-param>
    <description>Set the threshold size - files
    below this limit are stored in memory, files above
    this limit are stored on disk.
    Format: 10 - 10 bytes
    10k - 10 KB
    10m - 10 MB
    1g - 1 GB</description>
    <param-name>uploadThresholdSize</param-name>
    <param-value>100k</param-value>
    </init-param>
    </filter>
    <filter>
    <filter-name>No Caching Filter</filter-name>
    <filter-class>com.myco.nps_history.filters.NoCachingFilter</filter-class>
    </filter>
    <filter>
    <filter-name>SSOFilter</filter-name>
    <filter-class>com.myco.nps.im.plugin.NPSIMIntercepter</filter-class>
    <init-param>
    <param-name>filter_conf_file</param-name>
    <param-value>/export/third-party/etsbea/application_conf/wls_9.2.2/nps_history_gui_conf/nps_im_plugIn.properties</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>extensionsFilter</filter-name>
    <url-pattern>*.jsf</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>extensionsFilter</filter-name>
    <url-pattern>/faces/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>No Caching Filter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>SSOFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
    <description>Sets properties of History UI app</description>
    <display-name>HistoryInitServlet</display-name>
    <servlet-name>HistoryInitServlet</servlet-name>
    <servlet-class>com.myco.nps_history.servlets.HistoryInitServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>HistoryInitServlet</servlet-name>
    <url-pattern>/HistoryInitServlet</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>HistoryInitServlet</servlet-name>
    <url-pattern>/refresh</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    </web-app>
    ==================End web.xml=======================

    I got that error when using the request URL /myapp/ or /myapp/index.html.
    Regarding,
    At any way, you should map the ExtensionsFilter on the FacesServlet rather than on any url-pattern. Could you elaborate on what you mean? Maybe with an example?
    Thanks, - Dave

  • How can I prevent the flushing of the buffer until the playing is finished in AS3?

    How can I prevent the flushing of the buffer until the playing is finished in AS3?
    Is it possible?
    The buffer is emptied and flushed 10-11 seconds before the real end of the flv file.
    The file is locally saved and I stream it though crtmp server.
    I cannot seek the last 10 seconds because of empty buffer. How can I stop flash from flushing the buffer at end?

    i used the same code and i got it working correctly...
    thanx a lot fot it...
    now i have one more problem with it.
    Actually i created a new class 'ErrorDialog' and the function showErrorDialog() inside it.
    now i want the option YES_NO_OPTION and the function sayshowMsgDialog() returning int value indicating the option selected from the dialog box.
    I tried it with following code
    public
    static
    int
    confirmDialog( String message_in, Component parent_in, String title_in,
    int messageType_in )
    try
    JOptionPane pane = new JOptionPane( message_in, messageType_in,
    JOptionPane.YES_NO_OPTION );
    JDialog dialog = pane.createDialog( parent_in, title_in );
    dialog.setResizable( false );
    dialog.show();
    int optionType = -1;
    try
    optionType = ( ( Integer )( pane.getValue() ) ).intValue();
    catch( Exception ee )
    optionType = -1;
    dialog.dispose();
    return optionType;
    catch( Exception e )
    e.printStackTrace();
    but, since return is after dispose() it is throwing an error 'missing return value'
    can i get some kind of solution for this?
    waiting eagerly...........
    -Soni

  • My child accidentally rented a movie on Apple TV.  Is there a way to refund the rental if we don't watch it?  How can I prevent this from happening?  Is there a way to password protect future purchases?

    My child accidentally rented a movie on Apple TV.  Is there a way to refund the rental if we don't watch it? 
    How can I prevent this from happening?  Is there a way to password protect future purchases?

    Did you try Parental Controls?
    Apple TV: Understanding Restrictions (parental controls) - Apple Support
    See if that does the trick: I think there's a way for you to request a password for purchases, but still be logged in.

  • How can I prevent a PDF file from being copied, printed or downloaded? Students should only be able to view the text and and not distribute it in any way.

    How can I prevent a PDF file from being copied, printed or downloaded? Students should only be able to view the text and and not distribute it in any way.

    You can prevent it from being printed by applying a security policy to it
    in Acrobat. The rest can't be prevented, unless you spend  a LOT of money
    on DRM protection.

  • Regarding Mail:  When I return to my computer after it has gone to sleep, my accounts go offline, and are always asking me for the password.  THis is very annoying.  How can I prevent this?

    Regarding Mail:  When I return to my computer after it has gone to sleep, my accounts go offline, and are always asking me for the password.  THis is very annoying.  How can I prevent this?

    Back up all data.
    Launch the Keychain Access application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Keychain Access in the icon grid.
    Select the login keychain from the list on the left side of the Keychain Access window. If your default keychain has a different name, select that.
    If the lock icon in the top left corner of the window shows that the keychain is locked, click to unlock it. You'll be prompted for the keychain password, which is the same as your login password, unless you've changed it.
    Right-click or control-click the login entry in the list. From the menu that pops up, select Change Settings for Keychain "login". In the sheet that opens, uncheck both boxes, if not already unchecked.
    From the menu bar, select
    Keychain Access ▹ Preferences ▹ First Aid
    If the box marked Keep login keychain unlocked is not checked, check it.
    Select
    Keychain Access ▹ Keychain First Aid
    from the menu bar and repair the keychain. Quit Keychain Access.

  • Prior saved .pdf sometimes has blacked out content. How can I prevent this?

    I use Mac OS 9 Maverick, read email in Mail.app and Yahoo.Mail, switch between Safari and Firefox for browsing (because Safari does not allow Flash videos to appear on pages).  When I want to save an email or an html file or report as .pdf, I use Command-P and select Save As PDF from the Print popup.  Normally, I can go back years later and read the .pdf document in the Home File I filed it in using Adobe Reader.  Sometimes, however, when I open a .pdf file--and I cannot tell prior to opening it--all of the content has been blacked out.  It is as if someone redacted the document after filing it, which I don't do. 
    How can I prevent these redactions?  The content being blacked out varies from extremely personal and important health files to simple email correspondence I want to save.  Sometimes I have paid for a document and have to contact the publisher to send hard copy via USPS due to this problem.
    What am I missing here?  Do I need a specific plug-in?  Is there a way to retrieve the blacked-out content from my computer stored file?
    Peter

    This forum is only for discussions on the forums themselves. You should post your question in the apropriate product forum,
    http://forums.adobe.com/community/shockwave
    if your ptoblem is with Shockwave, or
    http://forums.adobe.com/community/flashplayer
    if it affects Flash Player.

  • How can I prevent Bridge from altering my photos?

    HELP!!!
    Within the past few days my Bridge CS4 program has been making my life miserable. I had been utilizing the program to batch photos from my extensive photo library, rename them, sort them (i.e., change sort/ordinal number), and the like without any difficulty and then suddenly, after executing such processes my thumbnails turned completely white and would not open in Bridge, Photoshop CS4 Extended - much less anything else. I tried reopening them as .jpg's, .psd's, .tiff's to no avail. I went into properties on each photo and checked the "open with" tab, and it noted that the photo was not recognized. I had some moderate success opening them with Quicktime Picture Viewer, but converting them back to a Bridge readable format (i.e., their original state) proved impossible. Having noticed that Quicktime had hijacked nearly my entire photo opening process, I uninstalled it in the hope that it would solve the problem. It didn't. I then went into Bridge and Photoshop CS4 preferences to try and modify how photos were opened, and couldn't seem to find anything applicable. I did, however, increase the memory and cache allocated to each program substantially.
    Last night I ran into more problems with Bridge. While scanning both photo negatives and prints into Bridge and saving them into various files, I encountered the same problem indicated in paragraph one. I tried scanning several of them a second time and succeeded; however, I had to save them to a different file and give them dissimilar names in .tiff format. In the process I found more than a dozen ways to spell "Mexico," "Tokyo," and "Ukraine"! They would not save as .jpg's or .psd's.
    I use Windows Vista Home Premium SP1, have a Pentium 4 Dual Core (2.8) processor, 4 GB Memory, Nvidia GE Force 7600 video card (yes, the drivers are up to date), and Hewlett Packard Photosmart C7180 and C7280 printers for scanning. All of the photos involved are stored on a Maxtor One Touch 1TB Turbo auxillary hard drive.
    Also, could anyone suggest how I can get the  SD/MMC card reader on my PC to work?
    Thanks to any and all for assisting me with my problem.
    Wolfgang Holst
    Big Bear Lake, CA

    Thank you curt y for your quick response. I have seen your recommendations on the adobe forums link in the past and many of your solutions
    seem to have helped other people with Bridge problems. I took your suggestion and gave it a whirl - all preferences were restored to defaults - and the problem continues. I get the feeling the problems lies with the program's interaction with Windows.
    Having tried a few more things, I've found that I can move the photo shell (the inscription underneath the thumbnail states, "Window Shell Common") to my desktop and open it there with Photoshop (i.e., going through the song and dance of "open with" and clicking on the CS4 icon, where it opens up in RAW). I must then move it over to Photoshop CS4 and save it as a .jpg or a .psd. Unfortunately, after all this it still won't open in Bridge. By all appearances, Bridge somehow has become corrupted and I'm probably going to have to do a complete Photoshop CS4 uninstall and reinstall.
    I've spent hundreds - if not thousands - of hours scanning into my system some 10,000 photographs of my travels (yes, they are backed up on discs), and Bridge should not be negatively impacting my ability to organize and manipulation them as is happening now. If the uninstall/reinstall does not resolve the problem, I'll be back on this forum for more suggestions.
    As for the card reader issue, I'm well aware of the 2GB/over 2GB issue. I typically use a 4GB or more card in my camera. I can download fine through my HP 7180 and 7280 card readers, but my HP 1518n card reader is a different story. I'll work a little more on it, too.
    Thanks again.
    Wolfgang Holst
    Big Bear Lake, CA    
    Date: Thu, 18 Jun 2009 08:49:46 -0600
    From: [email protected]
    To: [email protected]
    Subject: How can I prevent Bridge from altering my photos?
    Have you tried resetting your preferences by holding down the Ctrl key and starting Bridge?  You will get a reset window, choose all 3 options.
    The only thing I know about card readers is that there are 2 versions.  One for cards of 2 gigs or less, and one for HD cards over 2 gigs.  Make sure card and reader match.
    >

  • How can I prevent the settings on iMessage from changing each time I sync the devices with iTunes on our iMac?

    Each time I sync an apple device (iPad, iPad mini, iPhone) with iTunes on our iMac the settings on iMessage and phone settings change. We use the same Apple ID and have different e-mail addresses and phone numbers; however, each time a device is sync'd on iTunes on our iMac, the iMessage settings and phone settings are changed so that we all each get each other's text messages and phone calls. After the device is sync'd/charged, I have to go into each device (all of them somehow update when only one is sync'ing) and re-set the settings to what we want. How can I prevent settings from being changed each time?

    Okay I've tried safe mode.  Let it run down to 98%, plugged it in, locked the screen, and waited.  A few minutes later, the screen came on showing the 100% icon at the top right, full battery icon just to the left of the time, 100% text to the left of that.
    I'm not going to do a hard reset until I have confirmation that this is not normal behavior for the phone because that's going to take hours of my time and gigabytes of data transfer to get all of my media and apps back on the phone and configured.
    After all my griping, I do have to give credit where it's due.  This phone is much more efficient than my Galaxy Nexus.  I left the S5 running in WiFi hotspot mode while on battery last night.  It still had over 50% left on the battery.  The Galaxy Nexus would be stone dead after about 4 hours.  I can live with that if I have to but I'd really rather be able to leave it on the charger at night.

  • My neighbour's Mac Book Pro shows up as discoverable when Bluetooth is turned on in my iPad Air.  How can I block her device?  How can I prevent her pairing with my iPad Air. I need Bluetooth on to play music over my system.

    My neighbour's Mac Book Pro shows up as discoverable in my Bluetooth list on my iPad Air.  How can I block her Bluetooth device? How can I prevent her pairing with my device?  I need Bluetooth to stream music on my Bose system.  Thanks!

    If your device is discoverable, the other BT device would try (I am not sure if that would be successful). If it was, it would appear in your system preferences>Bluetooth.
    Take a look at this re: security:
    http://support.apple.com/kb/PH10786
    This is from another Apple article:
    Use Bluetooth
    You can wirelessly transfer files between computers—even Mac to PC—using the Bluetooth File Exchange utility. You can even browse selected devices and retrieve files remotely. For extra security, you can stipulate that only trusted devices be allowed to connect to your Mac, and 128-bit over-the-air encryption is also available
    Barry
    P.S. Since I have not had the issue, I have not researched this before. Thank you for making me look into BT security
    Message was edited by: Barry Hemphill

  • If I have multiple email accounts, how can I prevent one of them from sending email?

    If set up multiple email accounts in Thunderbird, how can I prevent one of them from sending email, while allowing others to send?

    Simple answer:
    do not use the email address when sending or replying or forwarding emails. Sending is not automatic, you have to generate the email and click on a Send button.
    You could use an smtp server that will not allow sending using the incorrect server for the email address, so that it cannot send, but if you accidentally use the email address you may get an error message, but at least the email will not be sent. Do this here:
    Tools > Account Settings for the mail account.
    bottom right Outgoing Server - select one that will not accept sending using wrong email address
    OR
    in Outgoing Server(SMTP) select the server you are using for that account
    click on 'Edit'
    deliberately make an error in the server name - remove the port details etc.
    So the details are wrong and cannot send.

  • I'm always losing all of my music and get a lot of apps that i don't need when i plug my i4 into my mac. I only ticked the box 'Manually manage music and videos' but it's always syncing itself. How can i prevent this? I don't want to put bacPlease Help!!!

    I'm always losing all of my music and get a lot of apps that i don't need when i plug my i4 into my mac. I only ticked the box 'Manually manage music and videos' but it's always syncing itself. How can i prevent this? I don't want to put back 1500 any more because of this. Please Help!!!

    I'm always losing all of my music and get a lot of apps that i don't need when i plug my i4 into my mac. I only ticked the box 'Manually manage music and videos' but it's always syncing itself. How can i prevent this? I don't want to put back 1500 any more because of this. Please Help!!!

  • How can I prevent two different profiles from interfering with one another?

    I have a serious profiles problem. I created a new profile with Profile Manager and then copied a well-established profile's contents into its directory before starting the new profile. Now, when I start either profile, it contains whatever tabs I had in the previously opened profile. I deleted a bunch of tabs and a window from the new profile but when I opened it after having opened and closed the old profile, the tabs and window reappeared. If I open some tabs in the new profile and then close it and open the old profile, the tabs appear in it, and vice versa.
    I open the original profile through a shell script:
    <pre>/Applications/Firefox.app/Contents/MacOS/firefox -P "profile 1"</pre>
    I open the second one the same way but with the <i>-no-remote</i> parameter:
    <pre>/Applications/Firefox.app/Contents/MacOS/firefox -P "profile 1 clone" -no-remote</pre>
    Why do the two profiles collide like that and how can I prevent this from happening?

    Are you using Sync then ?
    Or are you setting a bunch of tabs as the homepage ?
    If you cloned a profile they will start off the same and that will include the set of open tabs from the file ''sessionstore.js'' however profiles are independent and so should have there own sessionstore and History once they have been used.

  • How can I prevent my texts showing on another family members iPhone?

    How can I prevent my texts showing on another family members iPhone?

    Stop using the same apple ID for iMessage on both phones.
    Your question has already been asked and answered many many times. Search before posting please.

  • How can I prevent my new Mac Air from freezing in Safari

    How can I prevent my new Mac Air from freezing in while using Safari?

    Hi nainmom,
    Thanks for visiting Apple Support Communities.
    I recommend starting with these steps if your iPod nano is not recognized by your Mac:
    iPod not recognized in iTunes and Mac desktop
    http://support.apple.com/kb/ts1410
    Best,
    Jeremy

Maybe you are looking for