Why does Java have transient fields?

前端 未结 15 1982
旧时难觅i
旧时难觅i 2020-11-22 03:54

Why does Java have transient fields?

15条回答
  •  鱼传尺愫
    2020-11-22 04:27

    transient is used to indicate that a class field doesn't need to be serialized. Probably the best example is a Thread field. There's usually no reason to serialize a Thread, as its state is very 'flow specific'.

提交回复
热议问题