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: 
Use the [Java Concurrency API](http://download.oracle.com/javase/1,5.0/docs/api/java/util/concurrent/package-summary.html). Usage of `BlockingQueue`s, `Future<>` will help you. 

Note: This is a classic producer-consumer problem. This can be achieved having a shared queue to hold data where one thread will push data into the queue and the othe will consume the data. Proper synchronisation is needed to achieve a correct solution. `BlockingQueue` implementations like `LinkedBlockingQueue` will be helpful.

Update: Part of you problem [the consumer] can be derived from [this](https://stackoverflow.com/questions/6301186/how-to-stop-a-thread-in-java-and-let-the-same-thread-to-do-another-thing/6302642#6302642) answer of mine. But this solution uses the simpler `wait`-`notify` approach.
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).