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
  • 15,555
  • 47
  • 142
  • 246

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
  • 209,639
  • 45
  • 409
  • 525
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,231
  • 9
  • 53
  • 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
  • 15,437
  • 2
  • 41
  • 82