@lalit hi its because whenever we talk about multi-threading we need to take care of synchronization as the problem clearly says "application made only single threaded " means not synchronized otherwise as a programmer its his job to make a app..for multithreaded environment so that such problem can avoided simultaneous access of any segment/part of this application causes curruption od data...let us take a example
Let us assume that two threads T1 and T2 each want to increment the value of a global integer by one. Ideally, the following sequence of operations would take place: 1. Integer i = 0; (memory) 2. T1 reads the value of i from memory into register1: 0 3. T1 increments the value of i in register1: (register1 contents) + 1 = 1 4. T1 stores the value of register1 in memory: 1 5. T2 reads the value of i from memory into register2: 1 6. T2 increments the value of i in register2: (register2 contents) + 1 = 2 7. T2 stores the value of register2 in memory: 2 8. Integer i = 2; (memory) In the case shown above, the final value of i is 2, as expected. However, if the two threads run simultaneously without locking or synchronization, the outcome of the operation could be wrong. The alternative sequence of operations below demonstrates this scenario: 1. Integer i = 0; (memory) 2. T1 reads the value of i from memory into register1: 0 3. T2 reads the value of i from memory into register2: 0 4. T1 increments the value of i in register1: (register1 contents) + 1 = 1 5. T2 increments the value of i in register2: (register2 contents) + 1 = 1 6. T1 stores the value of register1 in memory: 1 7. T2 stores the value of register2 in memory: 1 8. Integer i = 1; (memory) The final value of i is 1 instead of the expected result of 2. its the problem of synchronization..future solution of this problem is it is mutual exclusion..its not ended world computer science.. Hope It Will help You Thanks & Regards Shashank Mani Narayan "Don't Be Evil U Can Earn While U Learn" Cell No +91-9740852296 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.