[concurrency-interest] sharing a collection

First Last chancer357 at hotmail.com
Sat Jan 13 17:11:48 EST 2007

I have a Runnable that has a bunch of un-synchronized state, and I place 
that into an Executor
The task will do some calculations and update the state, this should be ok 
because only 1 thread has it.
Then the task will go and resubmit itself to the executor

class State {
  int x = ..;
  List<?> y = ...;

final ExecutorService executor = ...;

Runnable r = new Runnable() {
  State s = new State();
  public void run() {

    // add things to s.y
    // change s.x



Since it now may get picked up by another thread, will the other thread 
correctly see changes to that state?

Communicate instantly! Use your Hotmail address to sign into Windows Live 
Messenger now. http://get.live.com/messenger/overview

More information about the Concurrency-interest mailing list