0

Need to create a multiple user application in java with multiple insert at a time so i tried to maintain a queue using synchronized (this) in my program but it is not up to the mark. which will be the better option than synchronized. any help in this will be appreciated.

Prabakar Gutz
  • 37
  • 1
  • 2
  • 10
  • 5
    How is it not _up to the mark_? As always code helps – Reimeus Jan 22 '14 at 11:26
  • i have used select max(user)+1 from table inside synchronized of this and two person hitting the submit button at same time and at that time we are executing insert query for both. what i expected is it should insert into table (user)values(3) for one and insert into table (user)values(4) for another but both values are 3 .. – Prabakar Gutz Jan 22 '14 at 11:32

1 Answers1

0

How about maybe using Semaphores? They're really nice when you need to give access to more than one thread. I don't really know a lot, just what I've learned in class. Hope It'll help!

Here's a link to an example info on semaphores

Alex_t
  • 134
  • 4