Hi,

         I am new to groovy. Here I tried to create

a simple wrapper around 'sleep'.

I see the error in the subject at 'def'. What's wrong ?

Thanks,

Mohan

/**
 * Our custom sleep logic.
 */
trait ThreadSleeper {
     long ms
     Closure cl = {}

    /*Sleep with an action taken*/
    def  sleeperWithAction() {
        try{

            Thread.sleep ms, cl

        }catch( InterruptedException ie ){
            throw new SleepInterruptedException( ie, "Thread.sleep is
interrupted for "+
                                                      "some reason ["
+ ie.getMessage() +"]");
        }
    }


    /*If there is no action to be taken then we call this*/
    def  sleeper() {
        try{

            Thread.sleep ms

        }catch( InterruptedException ie ){
            throw new SleepInterruptedException( ie, "Thread.sleep is
interrupted for "+
                                                     "some reason [" +
ie.getMessage() +"]");
        }
    }
}

Reply via email to