5

There is an enum structure,but I don't understand the meaning of '0xDEAD - 2' in this enum.

enum TerminatedTypes {
    _not_terminated = 0xDEAD - 2,
    _thread_exiting,                            
    _thread_terminated,                          
    _vm_exited                                   
};

From the code above,What kind of benefit can I get?

The code above is in 'hotspot/src/share/vm/runtime/thread.hpp' in openjdk8.

I am studying source code of jdk,please help me.

hippietrail
  • 15,848
  • 18
  • 99
  • 158
yangyixiaof
  • 225
  • 4
  • 15

1 Answers1

12

It's a hex literal, being used as an eyecatcher (useful in debuggers) so that the _thread_terminated value will be 0xDEAD ("terminated thread" equals "dead").

There's a host of hex literals people use for things like that, such as DEADBEEF from the Jargon file, and so on.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953