Why I have such a piece of code, IP is defined in the new outside the Runnable will be an error (Local variable IP defined in an enclosing scope must be final or effectively final); But the req is not an error?
CodePudding user response:
Rewrite the thread class run method, the inside of the IP scope is IP to the outside of the thread class scope is the main methodThe new Runnable () is in a class of data
class Temp implements Runnable {
Public void the run () {
String IP="";
}
}