multithreading - Threads in Java getting NullPointerException -


i'm trying call thread in java. want check if thread interrupted or not. thread defined in class "scheduler". here's code:

        if (flag == true)          {         thread = new scheduler();         thread.start();         }           else          {         thread.interrupt();         }          public void run()          {             while (thread.isinterrupted() != true) // here npe...            {               //....            }         } 

is run() code snippet scheduler ? in run why have thread.isinterrupted() ? instead use

thread.currentthread().isinterrupted() 

also see constructor , thread variable declared


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -