2017-06-14 56 views
0

在Swing应用程序中,某些UI操作事件在执行 和UI时滞后,并冻结了几秒钟。当尝试检查使用Java事件队列被延迟并持有监视器几秒钟

ThreadInfo MonitorInfo[] monitors = threadInfo.getLockedMonitors(); 

StackTraceElement[] stackElements = threadInfo.getStackTrace(); 

显示器和连续线..到组件。

这只发生在webstart

例如:

**HOLDS MONITORS:** [[email protected], 
[email protected], 
[email protected], 
[email protected], 
[email protected], 
[email protected]] 
STACK TRACE: 
java.util.zip.Inflater.inflateBytes(Native Method) 
java.util.zip.Inflater.inflate(Unknown Source) 
java.util.zip.InflaterInputStream.read(Unknown Source) 
java.util.jar.JarVerifier$VerifierStream.read(Unknown Source) 
com.sun.deploy.security.JarVerifier.readAndMaybeSaveStreamTo(Unknown 
Source) 
com.sun.deploy.security.JarVerifier.authenticateJarEntry(Unknown Source) 
com.sun.deploy.security.EnhancedJarVerifier.validate(Unknown Source) 
com.sun.deploy.cache.CacheEntry$3.run(Unknown Source) 
com.sun.deploy.cache.CacheEntry$3.run(Unknown Source) 
java.security.AccessController.doPrivileged(Native Method) 
com.sun.deploy.cache.CacheEntry.getJarSigningData(Unknown Source) 
com.sun.deploy.cache.CachedJarFile.getSigningData(Unknown Source) 
com.sun.deploy.cache.CachedJarFile$JarFileEntry.getCodeSigners(Unknown 
Source) 
com.sun.deploy.security.DeployURLClassPath$JarLoader$2.getCodeSigners(
Unknown Source) 
java.net.URLClassLoader.defineClass(Unknown Source) 
java.net.URLClassLoader.access$100(Unknown Source) 
java.net.URLClassLoader$1.run(Unknown Source) 
java.net.URLClassLoader$1.run(Unknown Source) 
java.security.AccessController.doPrivileged(Native Method) 
java.net.URLClassLoader.findClass(Unknown Source) 
com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source) 
java.lang.ClassLoader.loadClass(Unknown Source) 
com.sun.jnlp.JNLPClassLoader.loadClass(Unknown Source) 
java.lang.ClassLoader.loadClass(Unknown Source) 
+0

不要对非引用内容使用引号格式! –

+1

使用SwingWorker将长时间运行/阻塞操作卸载到其他线程上下文(除了事件分派线程) – MadProgrammer

回答

0

你试过把电话给在单独的线程那些方法?因为你使用Swing,所以它主要是线程安全的。整个显示器是冻结还是只是窗口?

线程是简单的,如果你一直在回避他们:

Thread thread = new Thread(() -> intensiveMethod()); 
thread.start(); 

intensiveMethod在于冻结你的显示器,你调用该方法。如果不是您打电话给它,请尝试安装最新的JRE和JDK。

+0

它冻结了应用程序而不是Windows(使用单独的线程,线程t =新的线程()..它仅冻结几秒钟(5秒)到45,直到前一个线程完成其过程恢复 – rathinamsm

+0

@MadProgrammer建议使用'SwingWorker',你试过吗? –

+0

线程ID:70,名称:AWT-EventQueue-2,状态: RUNNABLE [ [email protected]] ACK TRACE: java.awt.GridBagLayout.preInitMaximumArraySizes(未知来源) java.awt.GridBagLayout.GetLayoutInfo(未知来源) java.awt.GridBagLayout.getLayoutInfo(未知源) java.awt.GridBagLayout.ArrangeGrid(Unkn自己的源) java.awt.GridBagLayout.arrangeGrid(来源不明) java.awt.GridBagLayout.layoutContainer(来源不明) java.awt.Container.layout(来源不明) java.awt.Container.doLayout(UN) – rathinamsm