V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
vemier
V2EX  ›  程序员

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

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