• 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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can any one please let me know when can we use synchronization with a example. I am in a great confusion regarding this thing.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Raghuram Kristipati:
Can any one please let me know when can we use synchronization with a example. I am in a great confusion regarding this thing.



Synchronization is *not* just some API that you use for a particular service, you really need to understand what you are doing.

Take a look at the Sun Threads Tutorial to start.

Henry
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Raghuram, welcome to the ranch! That tutorial is definitely the place to go. Since you asked about synchronization (just one part of threading) I'll venture a very short explanation.

Often when two threads share a resource it is necessary to make sure only one thread accesses it at a time. A resource can be any object or something outside the JVM. For example, a "race condition" is A Bad Thing that happens if I set a value on an object and some other thread changes it before I get around to using it. Synchronization is mostly about making the threads access something one at a time.

Note that in the tutorial synchronization is a ways down the page. You can do a lot of threading without having two threads share any resources so there's plenty to learn before synchronization.

Have fun! Ask more questions as you go!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic