[javasim-general] howto use wait_until?
Hung-ying Tyan
tyanh@fla.fujitsu.com
Wed, 12 Feb 2003 13:35:34 -0800
Peter,
I agree with you. I have another solution here you can try.
A small class I wrote is called WaitUntil and you can use it as:
for {set i 0} {$i<100} {incr i} {
# set parameters
run experiment
rt experiment stopAt 120000
# wait for runtime to stop
java::new WaitUtil [rt -q experiment]
# log results
reboot experiment
}
The class is attached below. Thanks for your feedback.
Hung-ying
===================================================
public class WaitUntil extends Thread
{
drcl.comp.ACARuntime runtime;
boolean done = false;
public WaitUntil(drcl.comp.ACARuntime r) throws InterruptedException
{
runtime = r;
synchronized (this) {
start();
if (!done)
this.wait(); // wait until the runtime stops
}
}
public void run()
{
while (!runtime.isStopped()) {
yield();
}
synchronized (this) {
done = true;
this.notify(); // notify the main thread
}
}
}
> -----Original Message-----
> From: javasim-announce-admin@cs.uiuc.edu [mailto:javasim-announce-
> admin@cs.uiuc.edu] On Behalf Of Peter Backx
> Sent: Monday, February 10, 2003 5:29 AM
> To: javasim-announce@cs.uiuc.edu
> Subject: RE: [javasim-general] howto use wait_until?
>
>
> Hung-ying,
>
> Thanks for the quick reply, comments inline.
>
>
> > A better alternative would be using Tcl script with a batch file:
> >
> > Make your script only run one case but make all the parameters
> > the arguments
> > to the script. So at the beginning of your script, it would look like:
>
> The disadvantage is of course that the entire simulation environment needs
> to be reloaded every time (a quite timeconsuming part in my simulations).
> Of
> course once everything is properly automated this should no longer be a
> major objection.
>
>
> > It is
> > getting weird
> > in implementation as a simulation thread is trying to reset the
> simulation
> > engine. We should probably make this work in the future release.
>
> I understand the problem to get this working. One of the things I tried
> was
> attaching a state listener to the runtime, but this results in the same
> problem again: the simulation rebooting itself. Maybe some kind of
> meta-proces or -simulation encapsulating the actual simulation could work,
> but I haven't got much time at the moment to investigate this and I'm not
> sure how this could impact performance.
>
>
> Thanks again for the help and for the great javasim,
>
> Peter
>
> _______________________________________________
> javasim-announce mailing list
> javasim-announce@cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/javasim-announce