What does idempotent method mean and what are the side effects in case of calling close method of java.lang.AutoCloseable?

后端 未结 3 676
予麋鹿
予麋鹿 2020-12-08 02:50

Java docs of close() method of java.lang.AutoCloseable says

Note that unlike the close() method of Closeable, this close() method is no

3条回答
  •  盖世英雄少女心
    2020-12-08 03:28

    JAVA GLOSSARY Idempotent

    If methods are written in such a way that repeated calls to the same method do not cause duplicate updates, the method is said to be "idempotent."

    In mathematics an idempotent element, or an idempotent for short, is anything that, when multiplied by itself, gives itself as result. For example, the only two real numbers which are idempotent are 0 and 1.

    In user interface design, a button can be called "idempotent" if pressing it more than once will have the same effect as pressing it once. For example, a "Pause" button is not idempotent if it toggles the paused state. On the other hand, if pressing it multiple times keeps the system paused and pressing "Play" resumes, then "Pause" is idempotent. This is useful in interfaces such as infrared remote controls and touch screens where the user may not be sure of having pressed the button successfully and may press it again. Elevator call buttons are also idempotent, though many people think they are not.

    Resource:-http://www.allapplabs.com/glossary/idempotent.htm

提交回复
热议问题