Java: is there no AtomicFloat or AtomicDouble?

后端 未结 8 1430
误落风尘
误落风尘 2020-12-01 03:12

I have found AtomicInteger, AtomicLong, but where is AtomicFloat (or AtomicDouble)? Maybe there is some trick?

8条回答
  •  执笔经年
    2020-12-01 04:11

    It's not a java issue, all languages suffer from this.

    The assembly instructions which the atomic compare and swap operations compile down to are variants of: http://x86.renejeschke.de/html/file_module_x86_id_41.html

    These all operate on integers and the pipelined nature of the FPU makes it much harder to implement for floats/doubles.

提交回复
热议问题