Home > Back-end >  Multithreaded problem bosses, genuflect is begged
Multithreaded problem bosses, genuflect is begged

Time:09-19

To ask people for their interface, request times more time-consuming longer to solve with multithreading,,

CodePudding user response:

Public static void main (String [] args) {
Final String name="nanjing";
for (int i=0; I & lt; 10; I++) {
Final int j=I;
Ex. The execute (new Runnable () {
@ Override
Public void the run () {
JSONObject json=new JSONObject();
Json. The put (" name ", name);
Json. The put (" start ", j);
System.out.println(json);
}
});
}
}

Keep the Shared variables is a fixed value, multi-threaded Shared variables under the concurrency problem is a little more, be sure to do this, you can use the Shared variables and synchronization

CodePudding user response:

refer to the original poster ShuaiXuXu response:
to ask people for their interface, request times more takes longer to solve with multithreading,,



Although didn't see your questions, but this code has a problem, as the upstairs said,
It is best to declare a child thread class, inside a no-parameter constructor
  • Related