When different threads access a static method, are objects declared in that method local or shared between threads in java?
Also, is it safe to call thread.interrupt() on a thread that is doing i/o?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Objects declared inside a
staticmethod are not shared between threads. Objects defined outside the method asstaticare shared.So:
If you’re going to be calling
interrupt()on threads doing I/O you should look at using classes that implement theInterruptableChannelinterface.