• 请不要在回答技术问题时复制粘贴 AI 生成的内容
vemier
V2EX  ›  程序员

高并发情况下如何保证检查并修改操作是线程安全的

  •  
  •   vemier · Sep 7, 2021 · 2591 views
    This topic created in 1886 days ago, the information mentioned may be changed or developed.
    如果这个检查操作比较复杂的话,有什么比较好的解决方案吗
    7 replies  •  2021-09-07 17:26:30 +08:00
    fmumu
    fmumu
    Sep 7, 2021
    1
    CAS 乐观锁
    mightofcode
    mightofcode
    Sep 7, 2021
    2
    你的并发有多大?
    vemier
    vemier
    OP
    Sep 7, 2021
    3
    @fmumu 查询条件比较复杂,比如有 join 查其他表的情况,这种可以用 CAS 吗
    vemier
    vemier
    OP
    Sep 7, 2021
    4
    @mightofcode 只是想讨论下这种情况怎么解决,感觉某些业务场景下会有这种问题。
    huang119412
    huang119412
    Sep 7, 2021❤️1
    5
    parallel > lock free(CAS) > synchronized > AQS
    wellsc
    wellsc
    Sep 7, 2021
    6
    五楼很全了
    mightofcode
    mightofcode
    Sep 7, 2021❤️1
    7
    绝大部分情况下加锁就够了,关键是锁不能写得太烂
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2285 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 11:42 · PVG 19:42 · LAX 03:42 · JFK 06:42
    ♥ Do have faith in what you're doing.