Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7997997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:06:32+00:00 2026-06-04T15:06:32+00:00

I have a piece of code that needs to run inside a Swing application

  • 0

I have a piece of code that needs to run inside a Swing application as well as in a webapplication. But it should do slightly different things in each environment. Therefore we check SwingUtilities.isEventDispatchThread()

After working fine for some time this suddenly stopped working. It just hangs on that call and never returns. Any idea why that might be?

We are on java 6, tomcat 7 on a linux box.

UPDATE:

We removed the call to isEventDispatchThread() so my immediate problem is solved, but I’m still interested in an answer why this is happening.

We debugged a little more, got a Thread dump and found the stuff below for one thread.
It shows many threads are waiting on it. So that explains the hanging.

java.awt.Toolkit.getDefaultToolkit seems to causing the lock since it is synchronized. So Yura was hinting in the right direction.

So the question remains: Why doesn’t it complete or to turn the question around why does sun.awt.X11GraphicsEnvironment.initDisplay(X11GraphicsEnvironment.java:-1) hang?

There is a X11 running on the machine ….

"http-bio-8081-exec-10@10344" daemon prio=5 tid=0x1ae nid=NA runnable
  java.lang.Thread.State: RUNNABLE
  blocks http-bio-8081-exec-13@10809
  blocks http-bio-8081-exec-12@10786
  blocks http-bio-8081-exec-11@10343
  blocks http-bio-8081-exec-9@10345
  blocks http-bio-8081-exec-7@10346
  blocks http-bio-8081-exec-6@10347
  blocks http-bio-8081-exec-4@10349
  blocks http-bio-8081-exec-3@10352
  blocks http-bio-8081-exec-2@10353
  blocks http-bio-8081-exec-1@10354
   at sun.awt.X11GraphicsEnvironment.initDisplay(X11GraphicsEnvironment.java:-1)
   at sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52)
   at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155)
   at java.security.AccessController.doPrivileged(AccessController.java:-1)
   at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131)
   at java.lang.Class.forName0(Class.java:-1)
   at java.lang.Class.forName(Class.java:169)
   at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
   - locked <0x2507> (a java.lang.Class)
   at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:89)
   at java.lang.Class.forName0(Class.java:-1)
   at java.lang.Class.forName(Class.java:169)
   at java.awt.Toolkit$2.run(Toolkit.java:834)
   at java.security.AccessController.doPrivileged(AccessController.java:-1)
   at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:826)
   - locked <0xf9d> (a java.lang.Class)
   at java.awt.Toolkit.getEventQueue(Toolkit.java:1689)
   at java.awt.EventQueue.isDispatchThread(EventQueue.java:857)
   at javax.swing.SwingUtilities.isEventDispatchThread(SwingUtilities.java:1339)
   at xxxxxxxxxA.setCurrentUser(xxxxxxxxxA.java:196)
   at xxxxxxxxxB.setCurrentUser(xxxxxxxxxB.java:41)
   at xxxxxxxxxC.UserThreadLocalHandler.afterCompletion(xxxxxxxxxC.java:96)
   at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletion(DispatcherServlet.java:1108)
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:830)
   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
   at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:58)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
   at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:162)
   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
   - locked <0x2a42> (a org.apache.tomcat.util.net.SocketWrapper)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:06:33+00:00Added an answer on June 4, 2026 at 3:06 pm

    Under the hood, SwingUtilities.isEventDispatchThread() invokes Toolkit.getEventQueue() method, which has following source:

    /* Accessor method for use by AWT package routines. */
    static EventQueue getEventQueue() {
        return getDefaultToolkit().getSystemEventQueueImpl();
    }
    

    Toolkit.getDefaultToolkit is declared as synchronized method – maybe this is the case. Also, please refer to JavaDoc of this method:
    http://docs.oracle.com/javase/6/docs/api/java/awt/Toolkit.html#getDefaultToolkit%28%29

    Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a piece of code that needs to be run from a restricted
I have a piece of code that needs to run every day at a
Here's an interesting architectural query. I have a piece of code that needs to
I have this piece of code that does not work: public CartaoCidadao() { InitializeComponent();
I have this piece of code that works fine in subsonic 2.2, I migrated
I have a piece of code that load a very big image in memory.
I have a piece of code that takes several rows from a database and
I have a piece of code that look similar to this: <xsl:choose> <xsl:when test=some_test>
I have a piece of code that calls a WCF service that is hosted
If have a piece of code that gets some data from a sql database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.