equal
deleted
inserted
replaced
2965 |
2965 |
2966 JVM_ENTRY(void, JVM_Yield(JNIEnv *env, jclass threadClass)) |
2966 JVM_ENTRY(void, JVM_Yield(JNIEnv *env, jclass threadClass)) |
2967 JVMWrapper("JVM_Yield"); |
2967 JVMWrapper("JVM_Yield"); |
2968 if (os::dont_yield()) return; |
2968 if (os::dont_yield()) return; |
2969 HOTSPOT_THREAD_YIELD(); |
2969 HOTSPOT_THREAD_YIELD(); |
2970 |
2970 os::naked_yield(); |
2971 // When ConvertYieldToSleep is off (default), this matches the classic VM use of yield. |
|
2972 // Critical for similar threading behaviour |
|
2973 if (ConvertYieldToSleep) { |
|
2974 os::sleep(thread, MinSleepInterval, false); |
|
2975 } else { |
|
2976 os::naked_yield(); |
|
2977 } |
|
2978 JVM_END |
2971 JVM_END |
2979 |
2972 |
2980 |
2973 |
2981 JVM_ENTRY(void, JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis)) |
2974 JVM_ENTRY(void, JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis)) |
2982 JVMWrapper("JVM_Sleep"); |
2975 JVMWrapper("JVM_Sleep"); |
2996 HOTSPOT_THREAD_SLEEP_BEGIN(millis); |
2989 HOTSPOT_THREAD_SLEEP_BEGIN(millis); |
2997 |
2990 |
2998 EventThreadSleep event; |
2991 EventThreadSleep event; |
2999 |
2992 |
3000 if (millis == 0) { |
2993 if (millis == 0) { |
3001 // When ConvertSleepToYield is on, this matches the classic VM implementation of |
2994 os::naked_yield(); |
3002 // JVM_Sleep. Critical for similar threading behaviour (Win32) |
|
3003 // It appears that in certain GUI contexts, it may be beneficial to do a short sleep |
|
3004 // for SOLARIS |
|
3005 if (ConvertSleepToYield) { |
|
3006 os::naked_yield(); |
|
3007 } else { |
|
3008 ThreadState old_state = thread->osthread()->get_state(); |
|
3009 thread->osthread()->set_state(SLEEPING); |
|
3010 os::sleep(thread, MinSleepInterval, false); |
|
3011 thread->osthread()->set_state(old_state); |
|
3012 } |
|
3013 } else { |
2995 } else { |
3014 ThreadState old_state = thread->osthread()->get_state(); |
2996 ThreadState old_state = thread->osthread()->get_state(); |
3015 thread->osthread()->set_state(SLEEPING); |
2997 thread->osthread()->set_state(SLEEPING); |
3016 if (os::sleep(thread, millis, true) == OS_INTRPT) { |
2998 if (os::sleep(thread, millis, true) == OS_INTRPT) { |
3017 // An asynchronous exception (e.g., ThreadDeathException) could have been thrown on |
2999 // An asynchronous exception (e.g., ThreadDeathException) could have been thrown on |