<i id='KMGEh'><tr id='KMGEh'><dt id='KMGEh'><q id='KMGEh'><span id='KMGEh'><b id='KMGEh'><form id='KMGEh'><ins id='KMGEh'></ins><ul id='KMGEh'></ul><sub id='KMGEh'></sub></form><legend id='KMGEh'></legend><bdo id='KMGEh'><pre id='KMGEh'><center id='KMGEh'></center></pre></bdo></b><th id='KMGEh'></th></span></q></dt></tr></i><div id='KMGEh'><tfoot id='KMGEh'></tfoot><dl id='KMGEh'><fieldset id='KMGEh'></fieldset></dl></div>
    • <bdo id='KMGEh'></bdo><ul id='KMGEh'></ul>

    <small id='KMGEh'></small><noframes id='KMGEh'>

      <legend id='KMGEh'><style id='KMGEh'><dir id='KMGEh'><q id='KMGEh'></q></dir></style></legend>

      <tfoot id='KMGEh'></tfoot>

        向正在运行的 JVM 发送信号

        Sending Signals to a Running JVM(向正在运行的 JVM 发送信号)
          <tbody id='us688'></tbody>

            <i id='us688'><tr id='us688'><dt id='us688'><q id='us688'><span id='us688'><b id='us688'><form id='us688'><ins id='us688'></ins><ul id='us688'></ul><sub id='us688'></sub></form><legend id='us688'></legend><bdo id='us688'><pre id='us688'><center id='us688'></center></pre></bdo></b><th id='us688'></th></span></q></dt></tr></i><div id='us688'><tfoot id='us688'></tfoot><dl id='us688'><fieldset id='us688'></fieldset></dl></div>
            • <small id='us688'></small><noframes id='us688'>

              <tfoot id='us688'></tfoot><legend id='us688'><style id='us688'><dir id='us688'><q id='us688'></q></dir></style></legend>

                  <bdo id='us688'></bdo><ul id='us688'></ul>
                  本文介绍了向正在运行的 JVM 发送信号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用自定义信号处理程序在自定义 Java 守护程序中捕获 TERM、ABRT 和 INT 信号.我在代码中有这个处理程序,以便我可以向它发送 TERM 信号并通过 kill 命令优雅地关闭程序.信号处理程序现在可以工作,但是当我编译代码时,我收到以下警告(多次):

                  I'm using a custom signal handler to catch TERM, ABRT and INT signals in a custom java daemon. I have this handler in the code so that I can send TERM signals to it and gracefully shutdown the program via the kill command. The signal handler works right now, but when I compile the code I'm receiving the following warning (many times over):

                  警告:sun.misc.SignalHandler 是 Sun 专有 API,可能会在未来的版本中删除

                  在使用这些类时:

                  import sun.misc.SignalHandler;
                  import sun.misc.Signal;
                  

                  有没有更好的方法向正在运行的 JVM 发送信号以启动主线程的关闭?我不喜欢将我的代码绑定到这个 API,因为它将来可能会被删除.

                  Is there a better way to send signals to a running JVM to initiate a shutdown of the main thread? I don't like having my code tied to this API when it could be removed in the future.

                  此代码现在可以在 Solaris 和 HPUX 上使用 1.5.0_22 JVM.任何帮助或建议将不胜感激.我使用 IBM 的这份文档来开发信号处理程序:

                  This code works on Solaris and HPUX today using 1.5.0_22 JVM. Any help or suggestions would be much appreciated. I used this document, from IBM, to develop the signal handler:

                  http://www.ibm.com/developerworks/java/library/i-信号处理/

                  推荐答案

                  首先要明白这只是sun.misc包的标准警告.他们让您知道您使用的 API 不是标准的 Java API.这并不意味着他们正在积极计划将来删除此 API.http://java.sun.com/products/jdk/常见问题解答/faq-sun-packages.html

                  First of all, understand that this is just a standard warning for sun.misc package. They're letting you know that the API you're using is not a standard Java API. It doesn't mean that they're actively planning to remove this API in the future. http://java.sun.com/products/jdk/faq/faq-sun-packages.html

                  就您的问题而言,我不太清楚为什么 java 进程处理终止信号的默认方式对您来说不够:如何优雅地停止java进程?.如果需要添加额外的逻辑,可以添加 关机钩子.

                  As far as your question, it's not quite clear to me why the default way java process handles kill signals is not sufficient for you: How to stop java process gracefully?. If you need to add additional logic, you can add a shutdown hook.

                  不过,如果您正在寻找其他方法让您的 java 进程知道该退出,您可以让它在套接字、标准输入或命名管道上侦听...

                  Still, If you're looking for other ways to let your java process know it's time to exit, you can have it listen on a socket, or stdin, or a named pipe...

                  您可能还想查看 JVMTI

                  这篇关于向正在运行的 JVM 发送信号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                • <i id='TwMiL'><tr id='TwMiL'><dt id='TwMiL'><q id='TwMiL'><span id='TwMiL'><b id='TwMiL'><form id='TwMiL'><ins id='TwMiL'></ins><ul id='TwMiL'></ul><sub id='TwMiL'></sub></form><legend id='TwMiL'></legend><bdo id='TwMiL'><pre id='TwMiL'><center id='TwMiL'></center></pre></bdo></b><th id='TwMiL'></th></span></q></dt></tr></i><div id='TwMiL'><tfoot id='TwMiL'></tfoot><dl id='TwMiL'><fieldset id='TwMiL'></fieldset></dl></div>

                    <bdo id='TwMiL'></bdo><ul id='TwMiL'></ul>
                        <tbody id='TwMiL'></tbody>

                        <small id='TwMiL'></small><noframes id='TwMiL'>

                        <legend id='TwMiL'><style id='TwMiL'><dir id='TwMiL'><q id='TwMiL'></q></dir></style></legend><tfoot id='TwMiL'></tfoot>