Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-23-2008, 07:04 AM
udayadas's Avatar
Member
 
Join Date: Aug 2008
Posts: 22
Rep Power: 0
udayadas is on a distinguished road
Post Synchronized Servlet
Just for the sake of testing...i declared by doGet()/doPost() as synchronized.It works.

But what could it actually mean.Does that make my servlet a single threaded servlet.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 08-27-2008, 06:10 PM
Senior Member
 
Join Date: Jun 2008
Posts: 902
Rep Power: 2
masijade is on a distinguished road
Default
It means you only get one connection at a time. Any additional connection would wait until the connections before it are finished.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 09-06-2008, 12:55 PM
Member
 
Join Date: Sep 2008
Posts: 17
Rep Power: 0
sagarbirari is on a distinguished road
Default
Hello

Yes . means at time only one thread can enter in doGet()/doPost() method.but this is not standard programming, Instead of used synchronized block on code,when you expect that more than 2 threads may operate on your code and they may inconsistent your data.


Regards
__________________
Sagar Birari

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 09-07-2008, 04:04 AM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 571
Rep Power: 2
fishtoprecords is on a distinguished road
Default
It means you won't be able to handle any load. Your application will not scale.

This is a crude solution that is not recommended.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 09-09-2008, 09:41 AM
Member
 
Join Date: Sep 2008
Posts: 17
Rep Power: 0
sagarbirari is on a distinguished road
Default
If you want performance then used synchronized block
__________________
Sagar Birari

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 09-09-2008, 08:14 PM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 571
Rep Power: 2
fishtoprecords is on a distinguished road
Default
Originally Posted by sagarbirari View Post
If you want performance then used synchronized block
This is way to general. And perhaps misleading. There is no difference between using a synchronized block and using synchronization on an object with the same scope as the block. The compiler just does the same thing as you would manually.

If you want to get performance and scaling, you have to carefully decide what needs synchronization and what types of locking it needs. The key is to obtain the fewest locks and locks of the weakest strength practical, for the shortest time.

Look at things like java.util.concurrent.locks.ReentrantReadWriteLock
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
servlet kondalrao.p Java Servlet 1 09-06-2008 01:10 PM
synchronized bugger New To Java 2 11-28-2007 10:33 AM
javax.servlet.ServletException: Wrapper cannot find servlet class util.t2 osval Advanced Java 1 08-07-2007 03:47 PM
doubt about synchronized simon Advanced Java 2 08-05-2007 03:49 AM
Return in the Middle of synchronized Block ariak Advanced Java 1 07-26-2007 10:24 AM


All times are GMT +2. The time now is 09:55 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org