You are updating the whole table A
inconditionally. Therefore (even with InnoDB) the whole table will be locked in exclusive mode for the time of the update. This lock is acquired and released automatically by the engine.
So you are safe, concurrency-wise. All concurrent threads will be put on hold when trying to read from A
until the update completes.
However (contrary to your last comment), all UPDATE
's will take place sequentially, and each of them will increment A.val
.