Hello, I'm trying execute a function repeatedly using scheduleAtFixedRate, however it's not working. my code;
PHP Code:
public static void KeepAlive(){
TimerTask tasknew = new TimerAction();
Timer t = new Timer(true);
// scheduling the task at fixed rate
t.scheduleAtFixedRate(tasknew, 0, 1 * 100);
System.out.println("execute KeepAlive");
}
static class TimerAction extends TimerTask {
public static void main(String[] args) throws SQLException{
System.out.println("execute TimerAction");
Connect conn = Connect.getInstance();
Statement st = conn.createStatement();
st.executeQuery("SELECT 1");
}
@Override
public void run() {
// TODO Auto-generated method stub
}
}
"execute KeepAlive" comes up when I execute the KeepAlive() function, but not "execute TimerAction".
any ideas what i'm doing wrong here?