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

      <bdo id='RJq4W'></bdo><ul id='RJq4W'></ul>

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

  1. <tfoot id='RJq4W'></tfoot>
    1. <small id='RJq4W'></small><noframes id='RJq4W'>

      在 jar 启动时预加载 java 类/库?

      Preloading java classes/libraries at jar startup?(在 jar 启动时预加载 java 类/库?)

    2. <legend id='Vl1sF'><style id='Vl1sF'><dir id='Vl1sF'><q id='Vl1sF'></q></dir></style></legend>
      <tfoot id='Vl1sF'></tfoot>
        • <bdo id='Vl1sF'></bdo><ul id='Vl1sF'></ul>

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

                <tbody id='Vl1sF'></tbody>
                <i id='Vl1sF'><tr id='Vl1sF'><dt id='Vl1sF'><q id='Vl1sF'><span id='Vl1sF'><b id='Vl1sF'><form id='Vl1sF'><ins id='Vl1sF'></ins><ul id='Vl1sF'></ul><sub id='Vl1sF'></sub></form><legend id='Vl1sF'></legend><bdo id='Vl1sF'><pre id='Vl1sF'><center id='Vl1sF'></center></pre></bdo></b><th id='Vl1sF'></th></span></q></dt></tr></i><div id='Vl1sF'><tfoot id='Vl1sF'></tfoot><dl id='Vl1sF'><fieldset id='Vl1sF'></fieldset></dl></div>
              1. 本文介绍了在 jar 启动时预加载 java 类/库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在对服务器的第一次 RPC 调用期间发生超时,但 subsequest 请求成功.服务器响应超时,因为在第一次调用时它会加载处理请求所需的库.由于此延迟,一些客户端超时.虽然可能会增加客户端的超时延迟,但我想尽量减少类加载对应用程序响应能力的影响.

                A time-out occurs during the first RPC call to a server yet subsequest requests succeed. The server times-out on the response because upon first call it loads the libraries needed to handle the request. Due to this delay, some clients time out. Although it is possible to increase the time-out delay in the client, I'd like to minimize the impact that class loading has on the application's responsiveness.

                您将如何预加载 Java 类文件,以便在首次运行应用程序的 .jar 文件时,类加载不会在第一次调用时引入延迟?

                How would you preload Java class files so that when the application's .jar file is first run class loading does not introduce a delay on the first call?

                推荐答案

                您可以在服务器上线之前运行负载.您尚未指定如何加载服务器、类以及环境是什么,但您可以利用类静态初始化程序将在加载类时运行这一事实.所以,如果你从main"方法运行,你的类可能看起来像这样

                You could run a load before the server becomes live. You haven't specified how you're loading the server, the classes, and what the environment is, but you can take advantage of the fact that a class static initializer will run when the class is loaded. So, if you're running from a "main" method, your class could look something like this

                public class Foo {
                
                   static {
                     //this will be run when the class is loaded
                     try { Class.forName("fully.qualified.class.name.that.i.want.to.Load"); }
                     catch ...
                   }
                
                   public static void main (string args[])
                   {
                    //run my server...
                   }
                }
                

                这篇关于在 jar 启动时预加载 java 类/库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Bytecode features not available in the Java language(Java 语言中不可用的字节码功能)
                ClassCastException because of classloaders?(ClassCastException 因为类加载器?)
                How can I add a Javaagent to a JVM without stopping the JVM?(如何在不停止 JVM 的情况下将 Javaagent 添加到 JVM?)
                Cannot load 64-bit SWT libraries on 32-bit JVM ( replacing SWT file )(无法在 32 位 JVM 上加载 64 位 SWT 库(替换 SWT 文件))
                Encourage the JVM to GC rather than grow the heap?(鼓励 JVM 进行 GC 而不是增加堆?)
                Why a sawtooth shaped graph?(为什么是锯齿形图形?)

                  <tbody id='jr8md'></tbody>
              2. <tfoot id='jr8md'></tfoot>
              3. <i id='jr8md'><tr id='jr8md'><dt id='jr8md'><q id='jr8md'><span id='jr8md'><b id='jr8md'><form id='jr8md'><ins id='jr8md'></ins><ul id='jr8md'></ul><sub id='jr8md'></sub></form><legend id='jr8md'></legend><bdo id='jr8md'><pre id='jr8md'><center id='jr8md'></center></pre></bdo></b><th id='jr8md'></th></span></q></dt></tr></i><div id='jr8md'><tfoot id='jr8md'></tfoot><dl id='jr8md'><fieldset id='jr8md'></fieldset></dl></div>

                    1. <legend id='jr8md'><style id='jr8md'><dir id='jr8md'><q id='jr8md'></q></dir></style></legend>
                      • <bdo id='jr8md'></bdo><ul id='jr8md'></ul>

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