ObjectDB ObjectDB

how to operate with same object but two different Thread on database.



   i have two thread one is for insert data another is for update data but in same object and same database.


i have three classes 


here declare variables and Getter and setter method constructor and to-string method.


Here i create a thread, create object of Gettersettetclass, i.e insert operation and pass that object to update.java class.


Here i want create another thread define a method which is for update operation. and i am getting that object here  which is passes from insert.java class.Then here i want to do update operation with that same object and same database.


So, point is two different operation, two different thread,one object(we can assume one table in sql), one database.

if it will possible, then what is the procedure.

if you want to see my code it is attach below,please see it once.

Thank you.


Usually multithreading with JPA involves multiple EntityManager instances, one per thread. Every thread with its own EntityManager has a private persistence context, i.e. the same database object is represented by multiple separate memory objects in different entity managers and threads. Locks are used to avoid conflict in updating the same object as the same time.

ObjectDB Support


To post on this website please sign in.