Skip to content

Instantly share code, notes, and snippets.

@kdabir
Last active November 20, 2017 08:26

Revisions

  1. kdabir revised this gist Feb 8, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,4 @@ Creating a `TimerTask` can not get easier than this thanks to groovy.

    To Run this:

    groovy https://gist.github.com/kdabir/3176945/raw/timer_example.groovy
    `groovy https://gist.github.com/kdabir/3176945/raw/timer_example.groovy`
  2. kdabir revised this gist Feb 8, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -3,3 +3,6 @@ Creating a `TimerTask` can not get easier than this thanks to groovy.
    - `import java.util.timer.*` is not required as java.util is already imported.
    - the `run()` is implemented as closure

    To Run this:

    groovy https://gist.github.com/kdabir/3176945/raw/timer_example.groovy
  3. kdabir revised this gist Jul 25, 2012. 2 changed files with 5 additions and 2 deletions.
    5 changes: 5 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    Creating a `TimerTask` can not get easier than this thanks to groovy.

    - `import java.util.timer.*` is not required as java.util is already imported.
    - the `run()` is implemented as closure

    2 changes: 0 additions & 2 deletions timer_example.groovy
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,3 @@
    import java.util.timer.*

    def count = 0

    new Timer().schedule({
  4. kdabir created this gist Jul 25, 2012.
    7 changes: 7 additions & 0 deletions timer_example.groovy
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    import java.util.timer.*

    def count = 0

    new Timer().schedule({
    println count++
    } as TimerTask, 1000, 3000) //magic numbers are initial-delay & repeat-interval