| Author |
synchronized block
|
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
In your opinion, If you compare these codes,What is differences, advantage of these?
|
 |
Stephan van Hulst
Bartender
Joined: Sep 20, 2010
Posts: 3050
|
|
There's nothing we can say about that, because a lot of context is missing.
Please post an SSCCE, and TellTheDetails.
|
 |
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
I want to to compare these:
|
 |
Jim Hoglund
Ranch Hand
Joined: Jan 09, 2008
Posts: 525
|
|
What do you think is different?
They look the same to me.
Jim ...
|
BEE MBA PMP SCJP-6
|
 |
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
What about these:
If you compare these,What differences you see?
|
 |
Jim Hoglund
Ranch Hand
Joined: Jan 09, 2008
Posts: 525
|
|
Again, what do you think is different?
What is your question?
Jim...
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
Jim Hoglund wrote:
What is your question?
Agreed. What is the question? Throwing out code, with "tell me about it" isn't very clear.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
|
It is said in some cases, It is possible that some threads,don't see the lock.I want to know how can this happened, and how to prevent this happened?
|
 |
agilemanoj kumar
Ranch Hand
Joined: Mar 07, 2008
Posts: 70
|
|
|
There is no difference between object lockObject and object of 'a' objectofa, if your concern is related to sequence of thread execution. You can synchronize your code using any type of object as long as this object is shared among all threads. In you code example, If I understood, both objects 'lockObject' and 'objectofa' is accessible and shared by Thread1 and Thread2. Hence, execution path will be fixed and predictable.
|
Manoj Kumar
|
 |
 |
|
|
subject: synchronized block
|
|
|