由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - 另一个入门问题。
相关主题
what is the use of thread.yield()?java的接口runnable
线程问题。请问关于用threadPoolExecutor实现threadpool的问题?
FrameWork of Thread application 1再问一个今天的面试题
ZT: 关于性爱的多线程问题研究(一)java ,wait ,notify notifyall
问个Thread 的问题,java certificate里的一道java题
Can Java thread return a value?NoThread concurrency
能这么 create thread 吗?好虫,exploit等大牛请进--关于htmlunit
implements runable 和 extends threadcore java多线程一般面试什么
相关话题的讨论汇总
话题: thread话题: 换出话题: yield话题: running话题: sleep
进入Java版参与讨论
1 (共1页)
j****g
发帖数: 597
1
Assuming that an interrupted exception has NOT been thrown and that "
aLiveThread" is a runnable thread, which three guarantee that a thread will
leave the running state?
A yield()
B wait()
C sleep(1000)
D aLiveThread.join()
B and D 肯定是对的。
答案说A是错的,说即使调用yield()不一定会导致该Thread被换出。但我的理解是调用
yield()以后一定会被换出。但是如果没有更高prority的Thread的话,该Thread可能会
再次进入running状态。意思就是肯定会leave running, 但是可能马上就被换入。
答案说C是对的。我的印象是即使调用sleep()也不一定会导致Thread被换出。因为印象
以前在sun工作站上做的时候sleep(250)没有导致当前Thread被换出。
牛人指教一下?
m******t
发帖数: 2416
2
I wouldn't sweat on A too much. It's just a matter of whether reading "
leaving the running state" literally. As long as everybody agrees that
yield() does not _always_ cause the thread to effectively yield the
processor, whether it literally leaves the "running" state in the state
diagram really is more theoretical than practical.
IIUC, in any decent JVM implementation, sleep() most certainly would cause a
thread to yeild control, because even if there aren't other application
threads suitable
1 (共1页)
进入Java版参与讨论
相关主题
core java多线程一般面试什么问个Thread 的问题,java certificate里的
ThreadLocal 的一个 use caseCan Java thread return a value?
请教一个多线程的问题能这么 create thread 吗?
java 程序中的实时控制implements runable 和 extends thread
what is the use of thread.yield()?java的接口runnable
线程问题。请问关于用threadPoolExecutor实现threadpool的问题?
FrameWork of Thread application 1再问一个今天的面试题
ZT: 关于性爱的多线程问题研究(一)java ,wait ,notify notifyall
相关话题的讨论汇总
话题: thread话题: 换出话题: yield话题: running话题: sleep