How do we save & update entities async?

Question

How do we save & update hibernate entities in an extra thread for not blocking our mainthread ?
I read many similar posts, but i never saw a real example.

It would be great if anyone could link or provide a small example of saving/updating entities without blocking the main thread during those operations.

Do a deep copy of the entities that you want flush and pass that to a different thread through some kind of thread safe queue. The other thread just needs to poll the queue and flush whatever was inserted into the queue. There is nothing special about this from a Hibernate perspective, but from a concurrency perspective you need to make sure there is no shared state as Hibernate needs to own these objects.