Reputation: 372
Is there a way to do non-blocking actions on the java interface of Berkeley DB and get the status and result of the action using a Future or something similar (like getting a result of a Callable using a Future)?
I don't want the thread calling the DB to be blocked until the DB action is done.
Upvotes: 2
Views: 420
Reputation: 372
from what I have seen in the API documentation, Berkeley DB JE does not have an asynchronous API. every call to the DB will block the calling thread until the action is done.
Upvotes: 1
Reputation: 382150
Yes, you can do it, as with any DB or resource, by simply creating a thread and starting it.
Runnable r = new Runnable() {
public void run() {
// call the DB
// call your callback to run other tasks after with the result
}
};
new Thread(r).start();
That's the standard way, in Java, to do asynchronous actions. You're in charge of the threads, contrary to javascript to which you seem to refer.
Upvotes: 0