Home  >  Q&A  >  body text

java - Why do multiple threads access the same resource?

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?

PHP中文网PHP中文网2657 days ago981

reply all(2)I'll reply

  • 扔个三星炸死你

    扔个三星炸死你2017-06-12 09:29:45

    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!!!!!!

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-06-12 09:29:45

    Because it has multi-core CPU

    reply
    0
  • Cancelreply