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
Post a Comment