Skip to main content

JTextArea and headless multithreaded application

2 replies [Last post]
Joined: 2010-09-29

Hi ;
I have an application trying to run in headless mode, then it starts multiple threads each thread try to use AWT to render an image
I do use JTextArea while rendering and i noticed that using JTextArea triggers KeyboardFocusManager.getCurrentKeyboardFocusManager which is a static synchronized method (meaning it will block other threads, trying to do the same thing at the same time), i also noticed that it install event listeners and Mouse/Keyboard listeners.

So, my question, Is using JTextArea in headless multithreaded app a good idea ? is there something else i can use that respect the headless state and not trigger keyboardFocuseHandler, should i expect my AWT based app to scale with more threads running in parallel or will thread blocking will become more of an issue ?

Sorry about the long question but i am new to AWT and the thread blocking starting to make me concerned about how my app will scale


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-07-24

Also regarding your question

> Is using JTextArea in headless multithreaded app a good idea ?

The answer is [b]definitely not[/b]. Baring the headless thing addressed in my previous message, Swing is a single-threaded GUI Toolkit, and everything that happens to a component such as the JTextArea should happen on the EDT only. This includes painting the component.

Joined: 2006-07-24


Just a few AWT component are really capable of working in the headless mode - specifically the Panel and the Canvas. Other components, including Swing components (eg JTextArea), are unsupported in this mode. Please refer to the technical article for more details on using the headless mode:

best regards,