Yes, this is pretty much the case with any multi-threaded system (UI or
otherwise).
On May 9, 2011, at 7:51 AM, Edvin Syse wrote:
> That makes sense :) Is it as expected that trying to manipulate the UI on a
> non-UI thread sometimes yields an error and other times not?
>
> -- Edvin
>
> Den 09.05.2011 13:45, skrev Greg Brown:
>> Using a Task is not a problem, but when you call back into the UI you need
>> to wrap it in a TaskAdapter. Tasks are executed on a background thread but
>> all UI calls need to happen on the main thread.
>>
>> On May 7, 2011, at 1:07 PM, Edvin Syse wrote:
>>
>>> If I pass --autologin=true to my app, there will be kicked off a Task with
>>> a TaskListener right away. Basically the flow is like this:
>>>
>>> 1. The application class loads a bxml file representing a Frame.
>>> 2. If --auto-login=true, call the login() method in the Frame
>>> 3. The login() method creates a task and a tasklistener, that would close
>>> the Frame and load another one on successful login.
>>>
>>> The first step is performed like this:
>>>
>>> LoginFrame loginFrame = (LoginFrame)
>>> serializer.readObject(VortexApplication.class, "LoginFrame.bxml");
>>> loginFrame.open(display, null);
>>>
>>> if ("true".equals(properties.get("autologin")))
>>> loginFrame.login();
>>>
>>> loginFrame.login() is basically:
>>>
>>> Task task = new Task() {
>>> ...
>>> }
>>>
>>> TaskListener loggedInListener = new TaskListener() {
>>> public void taskExecuted(Task task) {
>>> MainWindow mainWindow = (MainWindow)
>>> serializer.readObject(MainWindow.class, "MainWindow.bxml");
>>> mainWindow.open(display);
>>> close();
>>> ...
>>>
>>> Not a good idea? :)
>>>
>>> -- Edvin
>>>
>>>
>>>
>>> Den 07.05.2011 18:00, skrev Greg Brown:
>>>> Are you using background threads in your application by any chance?
>>>>
>>>> On May 7, 2011, at 9:41 AM, Edvin Syse wrote:
>>>>
>>>>> Once in a while I will get the following exception when I start my
>>>>> application. It appears maybe once every 30th start of the application.
>>>>> Since it is indeterministic I thought I'd post it here. I could create a
>>>>> test-case for this, but it could take some time to reproduce. Here goes:
>>>>>
>>>>> Exception in thread "AWT-EventQueue-0"
>>>>> java.util.ConcurrentModificationException
>>>>> at
>>>>> org.apache.pivot.collections.ArrayList$ArrayListItemIterator.hasNext(ArrayList.java:50)
>>>>> at
>>>>> org.apache.pivot.util.ImmutableIterator.hasNext(ImmutableIterator.java:37)
>>>>> at org.apache.pivot.wtk.skin.DisplaySkin.layout(DisplaySkin.java:49)
>>>>> at org.apache.pivot.wtk.Component.layout(Component.java:1951)
>>>>> at org.apache.pivot.wtk.Container.layout(Container.java:340)
>>>>> at org.apache.pivot.wtk.Component.validate(Component.java:1942)
>>>>> at
>>>>> org.apache.pivot.wtk.ApplicationContext$QueuedCallback.run(ApplicationContext.java:1488)
>>>>> at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
>>>>> at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
>>>>> at java.awt.EventQueue.access$000(EventQueue.java:84)
>>>>> at java.awt.EventQueue$1.run(EventQueue.java:602)
>>>>> at java.awt.EventQueue$1.run(EventQueue.java:600)
>>>>> at java.security.AccessController.doPrivileged(Native Method)
>>>>> at
>>>>> java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
>>>>> at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
>>>>> at
>>>>> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
>>>>> at
>>>>> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
>>>>> at
>>>>> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
>>>>> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
>>>>> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
>>>>> at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
>>>>>
>>>>> -- Edvin