GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java
Go To First  |  Previous Question  |  Next Question 
 Core Java  |  Question 11 of 502    Print  
Will there be a performance penalty if you make a method synchronized? If so, can you make any design changes to improve the performance

  
Total Answers and Comments: 3 Last Update: March 29, 2007   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Faisal Ghauri
 
Performance does take a hit when using synchronization. I think the way to reduce this hit is to synchronize only a block of code that will be accessed by threads and not synchronize the entire method. 
 


Above answer was rated as good by the following members:
damodarJ, rakesh_swarankar, geeksterrahul
June 27, 2005 05:00:30   #1  
Jayashree C.H        

RE: Will there be a performance penalty if you make a method synchronized? If so, can you make any des...
yes.the performance will be down if we use synchronization.
one can minimise the penalty by including garbage collection algorithm which reduces the cost of collecting large numbers of short- lived objects. and also by using Improved thread synchronization for invoking the synchronized methods.the invoking will be faster.

regards
Jayashree C.H

 
Is this answer useful? Yes | No
July 24, 2005 11:23:45   #2  
Faisal Ghauri        

RE: Will there be a performance penalty if you make a method synchronized? If so, can you make any des...
Performance does take a hit when using synchronization. I think the way to reduce this hit is to synchronize only a block of code that will be accessed by threads and not synchronize the entire method.


 
Is this answer useful? Yes | NoAnswer is useful 3   Answer is not useful 0Overall Rating: +3    
March 29, 2007 05:10:10   #3  
ganeshh        

RE: Will there be a performance penalty if you make a...
It is very useful because we can make only one thread to access the resources at a time with this we can avoid deadlock situation.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape