Best programming approach/methodology to assure thread safety

前端 未结 15 1887
一整个雨季
一整个雨季 2021-01-31 06:28

When I was learning Java coming from a background of some 20 years of procedural programming with basic, Pascal, COBOL and C, I thought at the time that the hardest thing about

15条回答
  •  耶瑟儿~
    2021-01-31 07:25

    1. Avoid sharing data between threads where possible (copy everything).
    2. Never have locks on method calls to external objects, where possible.
    3. Keep locks for the shortest amount of time possible.

提交回复
热议问题