currentThread « Operation « Java Thread Q&A

Home
Java Thread Q&A
1.concurrency
2.Development
3.Exception
4.Notify
5.Operation
6.Socket
7.State
8.synchronize
9.Thread Safe
10.ThreadPool
Java Thread Q&A » Operation » currentThread 

1. Why would you catch InterruptedException to call Thread.currentThread.interrupt()?    stackoverflow.com

In Effective Java (page 275), there is this code segment:

...
for (int i = 0; i < concurrency; i++) {
  executor.execute(new Runnable() {
    public void run() {
  ...

2. What's the difference between Thread.interrupt() and Thread.currentThread.interrupt() in Java?    stackoverflow.com

I wonder that whether Thread.interrupt() and Thread.currentThread.interrupt() do the same thing or will give the same result? If not, what's the difference? The similar quesiton is: what's the difference between Thread.sleep() and ...

3. Why invoke Thread.currentThread.interrupt() when catch any InterruptException?    stackoverflow.com

I saw many code invoke the method Thread.currentThread.interrupt() in the catch block, why?

4. wait() Vs Thread.currentThread().wait()    coderanch.com

Hi Java pals, Can any one help me in understanding the working calling wait() and calling Thread.currentThread().wait(). Case1> ... synchronized(this){ this.wait(); } ... Case2> ... synchronized(this){ Thread.currentThread.wait(); } ... Among the above specified code snippets, case1 invokes wait() on itself, which internally, puts the current executing thread on it into wait queue and releases the lock. In case2, we get the ...

5. Use of Thread.currentThread.yeald() for busy wait.    coderanch.com

Hi, I am trying to implement the bakery algorithm for mutual exclusion. For those of you familiar with it, you know that busy waiting is used in it. I have written the following code and it works fine. However, I do not understand why the code wont work if Thread.currenthread().yeald is not use.Why cant I use while(condition){} and let it loop. ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.