This is my Trigger that calls a matchService...
class TestJob {
def matchService
static triggers = {
cron name: 'firstThread', cronExpression: "0 0/1 12-13 ? * THU"
}
def group = "threadGroup"
def execute() {
matchService.playMatch()
println "run thread: " + String.format('%tH:%<tM:%<tS.%<tL',System.currentTimeMillis())
}
}
...this is the service that is called
class MatchException extends RuntimeException {
String message
Match match
}
class MatchService {
/*
* Rolls back database changes if errors occur
*/
static transactional = true
public void calc(Match m) {
println m.teamH.name + " - " + m.teamA.name
}
public playMatch() {
List<Match> matchList = new ArrayList()
Cal.get(1).matches.each{
match ->
matchList.add(match)
}
for(Match m: matchList) {
if(!m.validate()) {
throw new MatchException( message: "match not valid!!" , match:m)
}
calc(m)
}
}
}
what I'd like to do is to call the method calc N times in N threads to run synchronized. Is it also possible to update a gsp page in real time (without refresh the browser) with the new changes? Anybody can help me?