What is an “incompletely constructed object”?

前端 未结 3 1399
太阳男子
太阳男子 2020-11-28 12:14

Goetz\'s Java Concurrency in Practice, page 41, mentions how this reference can escape during construction. A \"don\'t do this\" example:

public         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 12:42

    Another problem arises when you subclass ThisEscape, and the child class invokes this consructor. The implicit this reference in the EventListener would have an incompletely constructed object.

提交回复
热议问题