Print

Print


Each thread clones its own separate Problem instance.  So put it in  
your Problem subclass, and clone it when the Problem is cloned like  
this:

     MyClass myObject;  // or myObject = new ....    [see setup below]

     public void setup(final EvolutionState state,
                       final Parameter base)
         {
         super.setup(state,base);
	// make the myObject here, loaded from the database or
	// just created from scratch.  You could also just make
	// it in the default constructor or assign it at top
	}

     public Object protoClone() throws CloneNotSupportedException
         {
         Object returnval = super.protoClone();
         myObject = (MyClass)(myObject.clone());
         return returnval;
         }



On Feb 7, 2006, at 10:20 AM, Sandeep Mulgund wrote:

> I'm using multiple evaluation threads in my ECJ-based application.   
> The
> fitness function needs to use a class that doesn't seem to like  
> concurrent
> access from multiple threads.  Is there any way I can allocate one  
> instance
> of this class per eval thread, and if so, where would it go?
>
> Thanks
>
> Sandeep