Results 1 to 5 of 5
- 10-12-2009, 11:09 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 3
- Rep Power
- 0
Which thread do the process first if we use multithreading ?
I have a common doubt. :confused:
If we use two synchronized threads simultaneously for reading and writing for a database, which thread will access first.
I mean,
We have two synchronized threads
Thread 1 for reading a database.
Thread 2 for writing to the same database.
If these two threads tries to do their process simultaneously which thread will access first the database (Read or write will happen first) ??
How to decide it ?? :confused:
Thanks a lot ..........
- 10-12-2009, 11:15 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
What do you mean by "two synchronized threads"?
The general answer is you can't tell which one runs first.
Certainly not without knowing what your code looks like.
- 10-12-2009, 11:20 AM #3
Member
- Join Date
- Oct 2009
- Posts
- 3
- Rep Power
- 0
r035198x,
thanks for ur quick reply,
I don't have much experience in multi thread programing. One interviewer asked this question to me. And i was so confused and couldn't answer for this.
So the answer is, we can't tell which one access the DB first, the system decide it. Right ??
- 10-12-2009, 11:21 AM #4
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Sort of, yes.
- 10-12-2009, 11:23 AM #5
Member
- Join Date
- Oct 2009
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Applet and multithreading
By pricelessjunk in forum Threads and SynchronizationReplies: 1Last Post: 08-03-2009, 09:47 PM -
multithreading
By shilpa.krishna in forum New To JavaReplies: 2Last Post: 06-27-2008, 04:18 PM -
Multithreading + Networking (desperate)
By bluebarca in forum New To JavaReplies: 1Last Post: 11-07-2007, 02:14 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks