What is Synchronization?
By veladitya
@veladitya (82)
India
March 12, 2007 5:48am CST
Wht is synchronization? how can we achieve in java?Wht is the use of it?
3 responses
@raghwagh (1527)
• India
12 Mar 07
Hi friend, actually synchronization is the concept related to threads.If we want that only one thread should access a piect of code of a method or a datamember then we can sorrund that piect of code with the word synchronize like synchronize{}
So the code to be synchronize should be in the curly braces.Also if you want to synchronize a method then add the word synchronize in the method declaration and your work is done.
1 person likes this
@jhawithu (1070)
• India
12 Apr 07
In serial data transmission, a method of ensuring that the receiving end can recognize characters in the order in which the transmitting end sent them, and can know where one character ends and the next begins. Without synchronization, the receiving end would perceive data simply as a series of binary digits with no relation to one another. Synchronous communication relies on a clocking mechanism to synchronize the signals between the sending and receiving machines.
@eminaren86 (106)
• India
13 Mar 07
because multithreading introduces an asynchronous behaviour to your programs,there must be a way for you to enforce synchronicity when you need it.for example if you want two threads to ommunicate and share a complicated data structure,such as a linked list,you need some way to ensure that ensure that they dont conflict with each other.that is,you must prevent one thread from writing data while another thread is in the middle of the reading it.for this purpose,java implements an elegant twist on an age-old model of interprocess synchronization:the monitor.the monitor is a control mechanism first defined by C.A.R Hoare.you can think of monitor as a very small box that can hold only one thread.once a thread enters monitor,all other threads must wait untill thread exists monitor.in this way,a monitor can be used to protect a shared asset from being manupulated by more than one thread at a time