![]() ![]() If the second thread was incrementing X by 1 also, it might finish, and then the computer resumes the original thread that was running. Without synchronization programming, the computer could stop the first thread at any point in time, and let the second access the variable. Synchronization is the process of eliminating these kinds of errors. Imagine the above situation with multiple threads trying to access the variable X at the same time. For example the line above could be broken down in to several operations, such as:Move the value of X into a register, move the value 1 into another register, add the two registers and place the value into a third register and finally move the added values into the memory address of the variable X. Computers use machine language, which could mean many separate operations for each line of code. But consider this line from a computer’s perspective. ![]() To a programmer the line X = X + 1 is a single operation. So what is thread synchronization? Imagine the following lines of code: Dim X as Integer ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |