File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Modify an object into a runnable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Modify an object into a runnable" Watch "Modify an object into a runnable" New topic

Modify an object into a runnable

Paulo Carvalho
Ranch Hand

Joined: Nov 12, 2008
Posts: 57

I have a class with an object which contains a list of Strings. In this class I have a runnable method where I want to access this object to add an element in his list.
However, it seems that in my runnable method, the object is not modified. No error is happening.

What can I do to solve my problem?

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 45359
Do you know that method is being executed? How do you know there is no error? What is in the catch following that try? Why are you doing that on the event dispatch thread?
Matthew Brown

Joined: Apr 06, 2010
Posts: 4541

Also...maybe there are bits missing that would change this interpretation, but it looks like you're asking the Runnable to be executed in another thread, but then immediately checking the size of the list. Even if the Runnable is being executed correctly, there's no reason to believe that it would have been executed by the time you check it.

(I'm assuming that line 15 should be o.getList().size() or similar)
I agree. Here's the link:
subject: Modify an object into a runnable
It's not a secret anymore!