Hello,
I have one task listener at task assignment. Inside the listener, it sends an email to user to tell the user that a task is assigned to him/her.
The trick is, I want to delay the code from running until the task data is submitted to database (for some reasons).
I tried to get a reference of the thread from listener and wait it to complete in a threadpool task. But it seems it doesn’t work every time. Mostly it starts after the timeout set in join() method.
Any ideas?
I’m using Tomcat distribution. Version 7.20.
public static void execute(Thread sourceThread, String emailContent) {
// executor of a fixed threadpool
executor.submit(() -> {
try {
sourceThread.join(20000);
} catch (InterruptedException e) {
//error handling
}
sendEmailHere();
});
}