Hi all,
I have a problem about thread synchronization.I have 3 threads.These threads runnable class.
-----------------------------------------------------------------------------------------------------------------------
This class create thread and run method go database table and get one row.Then update one column of this row.
----------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
My problem is that first thread get one database record and update one row.My getAJob() method is synchronize method.But thread 1 get first row and update row, thread2 get also same row and update row.thread 3 get same row and update.But my method synchronize method.If thread 1 is in getAjob() method,thread 2 and thread3 must wait I think.I want to that for example thread1 run and run getAjob() method,thread 2 and thread 3 wait in the meantime.Then when thread1 exit getAjob() method thread2 run getAjob() method.How can I do this?How can I solve my problem?
.
I have a problem about thread synchronization.I have 3 threads.These threads runnable class.
-----------------------------------------------------------------------------------------------------------------------
This class create thread and run method go database table and get one row.Then update one column of this row.
----------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
My problem is that first thread get one database record and update one row.My getAJob() method is synchronize method.But thread 1 get first row and update row, thread2 get also same row and update row.thread 3 get same row and update.But my method synchronize method.If thread 1 is in getAjob() method,thread 2 and thread3 must wait I think.I want to that for example thread1 run and run getAjob() method,thread 2 and thread 3 wait in the meantime.Then when thread1 exit getAjob() method thread2 run getAjob() method.How can I do this?How can I solve my problem?
.