本文介绍了设置java.awt.headless = true有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经历了

  1. 以编程方式设置java.awt.headless = true
  2. http://www.oracle.com/technetwork/articles/javase/headless-136834.html
  3. 其他一些链接.
  1. Setting java.awt.headless=true programmatically
  2. http://www.oracle.com/technetwork/articles/javase/headless-136834.htmland
  3. Some other links too.

没有地方解释使用此标志的好处.

Nowhere it is explained the benefit of using this flag.

这是性能优势吗?如果是,那么是否有一个粗略的量化标准将带来多少性能优势? (我知道对性能问题的回答完全取决于具体情况,但是很高兴知道是否有人从这样做中受益匪浅.)

Is it a performance benefit? If yes, is there even a rough quntization how much performance benefit there will be? (I know that answers to performance questions totally depend upon case to case, but it would be nice to know if someone reported a good benefit from doing this).

推荐答案

无头和非无头模式是不同的,它们具有不同的功能集.如果您只需要做一些简单的事情,例如字体渲染,那么可以,您将可以在无头模式下完成它.

Headless and non-headless modes are different, they have different set of features. If you only need to do some simple things like font rendering then yes, you will be able to do it in headless mode.

您始终可以检查JDK源代码的内脏,并亲自查看哪些方法依赖于非无头模式.但是我认为,即使性能提升可以忽略不计,最好还是通过java.awt.headless(如果您不需要完全" GUI模式).

You can always check the guts of the JDK sources and see for yourself, what methods are dependent on non-headless mode. But in my opinion, even if the performance gain is negligible, it's best to pass java.awt.headless anyway (if you do not need "full" GUI mode).

任何供应商都可以使用此属性.如果您拥有完整的GUI,则永远不会知道他们是否会做某事.因此,我的经验法则是:始终对控制台应用程序和服务器使用java.awt.headless.没关系.

Any vendor can use this property. You never know if they are going to do something if you have the full GUI. So, my rule of thumb is: always use java.awt.headless for the console apps and the servers. It won't harm.

这篇关于设置java.awt.headless = true有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 13:02