There is a stream:
Thread t = new Thread(new Runnable() {...}); It has an infinite while (true) . If I some time after starting the stream
t.start(); I will execute this code
t = null; will my endless loop inside this thread be stopped?
There is a stream:
Thread t = new Thread(new Runnable() {...}); It has an infinite while (true) . If I some time after starting the stream
t.start(); I will execute this code
t = null; will my endless loop inside this thread be stopped?
Not. Only the stop() method can stop the loop and, accordingly, the thread itself.
t.stop(); This
t = null; or
t.interrupt(); will not lead to anything. I just checked it myself.
stop() method is deprecated and not recommended for use. For interrupt() to work, your thread must be in an interrupted wait state. Read javadoc. The spear method gives a wrong idea about things. - a_guraSocket.connect(...) with a timeout in seconds, and also indicates the waiting time for the incoming stream. I read Javadoc, from the useful I found only the stop() method. What kind of spear method do you mean? I answered not at random and not thoughtlessly. - nickI compiled a test application, where at startup a thread is created and started, and the back button becomes null . The result: nothing flies, but the cycle continues its work.
Source: https://ru.stackoverflow.com/questions/575520/
All Articles
NullPointerExceptionwill crash - Flippyt = null? - nick