1

I was going through the thread class in java and found that most of its methods like sleep(), yield(), currentThread() are native. I know the meaning of native keyword but how can i check the JNI implementation for these methods?

Abhilash28
  • 645
  • 1
  • 9
  • 15
  • From the OpenJDK repo, here's where Thread's methods are registered: http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/3ad03712ea43/src/share/native/java/lang/Thread.c You'll have to grep around a little to find the implementations. – Jeffrey Bosboom May 05 '15 at 17:39
  • 1
    Duplicate of https://stackoverflow.com/questions/2292629/where-to-find-source-code-for-java-lang-native-methods – dhke May 05 '15 at 17:41
  • Since all the implementations are OS-specific, you will most likely end up somewhere in `os_foo.cpp`, e.g. for Linux, `JVM_yield()` ends up in http://hg.openjdk.java.net/jdk8u/jdk8u-dev/hotspot/file/c9f8b7319d0a/src/os/linux/vm/os_linux.cpp#l3827, where it finally calls `sched_yield()`. – dhke May 05 '15 at 17:51

0 Answers0