0

Hey all, Im working in IBM Websphere ILOG JRules 7.0 using RuleStudio (modified Eclipse) and am having an issue trying to implement a TimerTask.

I created a Techincal Rule based off a different rule that I know works and tried to add some code that would wait 5 seconds and then send a secondary message. I tried this via the following code:

int interval = 5000; // 5 sec
java.util.Date timeToRun = new java.util.Date(System.currentTimeMillis() + interval);
java.util.Timer timer = new java.util.Timer();

timer.schedule(new java.util.TimerTask() {
        public void run() {
            //  Message Sent Here
        }
    }, timeToRun); 

However, this code does not compile. The error it points out is on the open bracket right after new java.util.TimerTask() and the error messag is at token "{".

Some interesting observations though:

-I tried doing java.util.TimerTask test = new java.util.TimerTask(); and it throws an error at new java.util.TimerTask(); saying Could not find a public constructor (or argument mismatch) for java.util.TimerTask. Which I find odd since it's defintaly imported.

-I have Java version 1.6.0_17 installed on my comp, if it matters.

Thanks!

Hershizer33
  • 1,206
  • 2
  • 23
  • 46

2 Answers2

0

I have no experience with ILOG, but I'm guessing that this will probably work better:

java.util.Timer timer = new java.util.Timer();

class MyTask extends java.util.TimerTask {
    public void run() {
        //  Message Sent Here
    }
}

timer.schedule(new MyTask(), timeToRun);

If that still doesn't work, take MyTask out of the method.

Jon Bright
  • 13,388
  • 3
  • 31
  • 46
  • Didn't work, with the same `at token "{"` error on the open bracket after TimerTask... its like it has no clue what TimerTask is even when I directly import it. – Hershizer33 Apr 18 '11 at 21:30
0

Noticed this was still open, turned out that the engine we were using has a customized java library on it that didnt include TimerTask... doh. Went with a thread sleep command that the library actually had.

Hershizer33
  • 1,206
  • 2
  • 23
  • 46