Question: I want to make a background task in one thread and send information from that thread to another thread which runs the main program and update the information each period of time.

Thread1:

```
public void doTask()
{
    // ...
    someData = ...;
}

```

Thread2:

```
SwingUtilities.invokeLater(new Runnable()
{
    public void run()
    {
        new MainFrame(someData);
    }
});

```

How could I achieve this in java?

Answer: 
Java doesn't have a direct mechanism for a specific thread to send a message to another SPECIFIC thread. 

But there are indirect ways of achieving this though. For example, you can define a message queue object on one thread and then pass a reference to that queue to the second thread. The second thread can insert message objects into this queue; and the first thread can keep polling the queue to get itself alerted to new messages.

Also answered in this thread

[Communicating between two threads](https://stackoverflow.com/questions/6916398/communicating-between-2-threads)

The above link has some sample (pseudo) code.
This is maybe an overengineered aproach for this case, but nonetheless you could use [EventBus](http://eventbus.org/) - each Thread could publish and be subsrcibed to events.

An example is [here](http://bwinterberg.blogspot.com/2009/05/eventbus-library.html).