• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Synchronization vs SingleThreadModel

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I like to know difference between Synchronization and SingleThreadModel.

- bhuvan
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What definitions have you found so far? We like to make you do all the work here, just jump in when you're really stuck.
 
somin bhuvan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I think,

1)SingleThreadModel is used in server side and Synchronization is used in client side.
2)SingleThreadModel is for servlets and Synchronization is for Multithreading.

This is the difference i knew. But the thing is both do the same function and i want to know some more differences.

If am wrong please correct me.
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Synchronization is a way to prevent two threads from accessing the same resource (object) at the same time. The first one to ask for access wins, the second one blocks until the first one is done.

In the Single Threaded Model in the servlet container, the container synchronizes on the servlet for you and assures that only one thread accesses it at a time. So the servlet can safely assume only one thread will execute its code at a time.

Synchronization always poses a performance risk. It's like forcing a room full of people to exit through one door in single file. It takes longer than letting them use many doors. You might not notice the difference with only a few threads but it can make a big difference in a web server with hundreds or thousands of users.
 
Do you pee on your compost? Does this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic