Suppose I have a simple Model
package models;
import javax.persistence.Entity;
import play.db.jpa.Model;
@Entity
public class Chart extends Model {
public String name;
@Lob
public String json;
}
Now if I were to retrieve an object from the Chart class in a method as follows
Chart c = Chart.findById(1L);
doSomethingWithChartAndLetMeKnow(c)
c.wait();
Now in this doSomethingWithChartAndLetMeKnow method, once I finish processing, I can call c.notifyAll() and presumably the original method would continue executing.
However, what if a completely different method does the following
Chart c = Chart.findById(1L);
c.notifyAll();
would the original thread that was waiting on the doSomethingWithChartAndLetMeKnow method be waken up at all?
No, it would not wake the original thread.
The two requests are handled by separate Sessions. Entities retrieved in different sessions are not the same Java object.
However, you should check out Play!’s async support instead of using notify() and wait():
http://www.playframework.org/documentation/1.2/asynchronous