If you want to perform the run method again, only to the new one thread instance start again?
CodePudding user response:
May submit multiple tasks with a thread poolCodePudding user response:
If you want to reuse the thread, the task in a queue, threads in a wait state, if another thread in a queue for task issued a notice, the waiting thread activation, remove the queue task execution, execution of the continue to wait for, can be used in Java Executors to generate a Service, then can use repeatedly,CodePudding user response:
You put your task wrote a class to implement the runnable interface, and then to use the new thread (your job), and then invoke the run methodCodePudding user response:
You can have new a Runnable, new threads can you take the Runnable object as parameterYou don't want to start a thread, you can directly call Runnable run method to execute the code
CodePudding user response:
Thread is finished, you're done your NEW another,In addition, the Run can be used inside the loop, ran to go,
CodePudding user response:
The Timer is what you want?CodePudding user response:
If I want to many times in the new thread to run for a period of the same code (for example, run the code), can't avoid create thread instance? Can not like a static method: just in order to call methods, do not need to create objects,