2

Possible Duplicate:
Can “this” ever be null in Java?

I have thread with thic code:

  @Override
  public void run() {
    try {
      process();
    } finally {
      Factory.close(this);
    }
  }

is there option that this can be null ?

Community
  • 1
  • 1
hudi
  • 14,603
  • 43
  • 135
  • 237

3 Answers3

4
is there option that this can be null

No. this reference cannot be null. It will always point to the Thread instance currently executing that code.

Rohit Jain
  • 203,151
  • 43
  • 392
  • 509
0

No nothing is at least wrong here. THIS is never null in JAVA. May be your problem is somewhere else. Try to submit more code

Festus Tamakloe
  • 11,241
  • 9
  • 50
  • 65
0

this cannot be null anywhere in Java, null means it points to no object, (it's just a junk variable). this means, in the object, you are now implementing, it should point to itself.

Mordechai
  • 14,445
  • 1
  • 39
  • 78