import ch.psi.pshell.device.Device 

before_readout = { double[] pos->  println (pos) }
before_readout = { double[] pos->  println (pos) }
before_readout = { double[] pos->  println (pos) }


task1 = {
     motor.moveRel(1.0)
     return motor.getPosition()
 }

task2 = {
     motor2.moveRel(1.0)
     return motor2.getPosition()
 }

task3 = {     
     return sin.read()
 }

task4 =  { ch.psi.pshell.device.Motor motor, double step ->
    print ("Moving " + motor.getName() + " step = " + step)
    motor.moveRel(step)
    return motor.getPosition()
}


//ret = parallelize(task1, task2, task3)

//ret = fork(task1, task2, task3)
//println (ret)
//ret = join(ret)


ret = parallelize(task4.rcurry(motor,1), task4.rcurry(motor2,1))


println (ret)
