What does '0xDEAD' mean in the following code?

余生长醉 提交于 2019-12-23 11:21:08

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/25735847/what-does-0xdead-mean-in-the-following-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!