Tuesday, January 24, 2017

sun.misc.Signal is internal proprietary API and may be removed

When you use code like the below code segment to intercept user incurred shutdown signal to do some setting before it shuts down, you get this compile-time warning.

SignalHandler handler = new SignalHandler () {
        public void handle(Signal signal) {
            System.out.println("Sutting down....");
            //do some cleaning or setting here
            System.exit(0);
        }
 };
 Signal.handle(new Signal("INT"), handler);
 Signal.handle(new Signal("TERM"), handler);
Warning: sun.misc.Signal is internal proprietary API and may be removed

You may alternatively use the following code to avoid the warning message.
Runtime.getRuntime().addShutdownHook(new Thread() {
      public void run() {
            System.out.println("Sutting down....");
            //do some cleaning or setting here
      }
});

-----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live




If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book for free here.

No comments:

Post a Comment