File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

synchronized block

 
abalfazl hossein
Ranch Hand
Posts: 635
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




In your opinion, If you compare these codes,What is differences, advantage of these?
 
Stephan van Hulst
Bartender
Pie
Posts: 4826
34
Chrome Netbeans IDE Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 635
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to to compare these:




 
Jim Hoglund
Ranch Hand
Posts: 525
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you think is different?
They look the same to me.

Jim ...
 
abalfazl hossein
Ranch Hand
Posts: 635
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about these:





If you compare these,What differences you see?
 
Jim Hoglund
Ranch Hand
Posts: 525
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, what do you think is different?
What is your question?

Jim...
 
Henry Wong
author
Marshal
Pie
Posts: 20823
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
abalfazl hossein
Ranch Hand
Posts: 635
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic