java - Why do multiple threads access the same resource?
PHP中文网2017-06-12 09:27:45
0
2
1065
As the title states, multi-threading is essentially a reasonable scheduling and allocation of CPU time slices to achieve seemingly concurrency, but in fact only one instruction is executed at a time. Why do multiple threads access a resource?
Because an operation on a resource may be composed of multiple instructions. Only when these multiple instructions are executed, the operation on the resource will be completed. If you have not finished executing these instructions, switch to other threads. Macroscopically speaking There will be situations where multiple threads access the same resource
And, who said that there is actually only one instruction executed at a moment? Who says multi-threading is only about apparent concurrency? Don’t you know the existence of Multi-core CPU!!!!!!
Because an operation on a resource may be composed of multiple instructions. Only when these multiple instructions are executed, the operation on the resource will be completed. If you have not finished executing these instructions, switch to other threads. Macroscopically speaking There will be situations where multiple threads access the same resource
And, who said that there is actually only one instruction executed at a moment? Who says multi-threading is only about apparent concurrency? Don’t you know the existence of
Multi-core CPU
!!!!!!Because it has multi-core CPU