There are lots of possible places. But my top choice: in the setup()
method of your Problem. Problem is a Prototype, so one Problem will
be instantiated, then setup() will be called on it, then clone() will
be called on it many times and ECJ will use the clones. If you wish
all your Problem instances to share your data, then put it in an
instance variable during setup(), and don't touch the variable during
clone(). If you wish your Problem instances to have their own
copies, then copy the variable to the cloned object during clone().
Be sure to call super.clone(). See Prototype for more info.
Sean
On Dec 6, 2007, at 11:04 PM, Michael B Sullivan wrote:
> Hi All,
>
> I have a simple question: What would be the best way to have some
> initialization code called at the beginning of an ECJ run (before
> the evaluation threads are spawned)?
>
> I have an evaluation function which requires data to be loaded into
> memory before the first time it is run. Currently, I have it such
> that the data is loaded upon the first time it is called, but I
> could load the data through an initialization function (or some
> equivalent), if necessary.
>
> My problem is that a multithreaded ECJ run will call the function
> multiple times before the data is fully loaded into memory,
> resulting in ugly results for the first couple evaluations.
>
> If this issue doesn't fit nicely into the ECJ world view, I can fix
> it with mutex locks, etc. However, if there's an easy way to
> execute code at the beginning of an ECJ run, I would love to hear it.
>
> Thanks!
> Mike
|