https://blog.acolyer.org/2017/08/30/a-concurrent-perspective-on-smart-contracts/

Central insight: “… smart contracts need to deal with concurrent execution.” “Accounts using smart contracts in a blockchain are like threads using concurrent objects in shared memory”

  • blockchain ~ shared memory
  • accessible by many parties
  • smart contract ~ concurrent object
  • accessing them without good synchronization —> data races + loss of data and data integrity
  • account ~ thread
  • concurrent objects (smart contracts) invoked by threads (accounts)

Differences between traditional concurrent objects and smart contracts:

  • smart contract’s methods are atomic due to transactional model of computation
  • sequential execution of instructions after a contract is called no interrupts
  • but atomicity is not for free - concurrent behaviour noticeable at blockchain level!

How?

  1. The order of transactions can change the outcome in a block.
  2. Contract logic can spread across several blockchain transactions.
  3. Contracts that call other contracts exhibit cooperative multi-tasking, a yield. The caller might call code that it had not anticipated.
  4. Contracts can be used as service managing access to shared resource.