我是看SCJP的书把头搞晕了。 按照书上说的: calling your thread's start() method doesn't immediately cause the thread to run ; it just makes the thread eligible to run.The thread must still contend for CPU time with oter threads. 照这样说,start()方法也是让线程有机会运行,不过按rainly1985(鹏)的说法“start 之后就肯定会运行的,但是notify之后是有可能”,这样理解的话,start()就不是精确答案了。shenpipi(皮皮) 从调度者和被调度者的观点来看,感觉不是关键所在。两个方法的用法还是明确的,就是感觉题目有点迷糊 附notify()的用法: The notify() method arbitrarily selects one of the threads in the monitor's wating pool and moves it to the Seeking Lock State.
搞那么清楚干什么?反正自己心里明白就行了.学java又不是为了做题.
please read the question once more, everyone. It means when can the current object can be accessed by some threads but not when the thread can run. So b is the correct answer.If the question is changed to be what method call is used to tell a thread that it can be run? So the answer is C. But why isnot d. Bucause as usual, run method will not be intented to be called directed. Instend, we should call the method start, and then the thread object will call the run method to do the exactly job automatically.
偶准备下周考SCJP啊,兄弟 What method call is used to tell a thread that it has the opportunity to run?what method call is used to tell a thread that it can be run?有区别吗? shenpipi(皮皮)说的还有点想得通“ start 之后就肯定会运行的,但是notify之后是有可能,因为可能被等待同一个锁的其他线程抢先执行”
而b则是让线程进入lock pool,等待对象的锁被其他线程释放,一旦释放就运行所以opportunity这个词,用的有毛病
按照书上说的:
calling your thread's start() method doesn't immediately cause the thread to run ; it just
makes the thread eligible to run.The thread must still contend for CPU time with oter threads.
照这样说,start()方法也是让线程有机会运行,不过按rainly1985(鹏)的说法“start 之后就肯定会运行的,但是notify之后是有可能”,这样理解的话,start()就不是精确答案了。shenpipi(皮皮) 从调度者和被调度者的观点来看,感觉不是关键所在。两个方法的用法还是明确的,就是感觉题目有点迷糊
附notify()的用法:
The notify() method arbitrarily selects one of the threads in the monitor's wating pool and
moves it to the Seeking Lock State.
It means when can the current object can be accessed by some threads but not when the thread can run.
So b is the correct answer.If the question is changed to be what method call is used to tell a thread that it can be run? So the answer is C.
But why isnot d.
Bucause as usual, run method will not be intented to be called directed. Instend, we should call the method start, and then the thread object will call the run method to do the exactly job automatically.
What method call is used to tell a thread that it has the opportunity to run?what method call is used to tell a thread that it can be run?有区别吗?
shenpipi(皮皮)说的还有点想得通“
start 之后就肯定会运行的,但是notify之后是有可能,因为可能被等待同一个锁的其他线程抢先执行”