How to implement a multithreading
This article shows you how to implement a multi-threaded, concise and easy to understand content, absolutely can make your eyes shine, through the detailed introduction of this article I hope you can gain something.
Traditional thread test: * Child thread loop 10 times, then main thread loop 100 times, then back to child thread loop 10 times, then back to main thread loop 100 times, so loop 50 times, please write the program. package com.lau.javabase.lock;import java.util.concurrent.ExecutorService;import java. util.concurrent. Executives;/** * Traditional thread test: * Child thread loop 10 times, then main thread loop 100 times, then back to child thread loop 10 times, then back to main thread loop 100 times, so loop 50 times, please write the program. */public class TraditionThreadExerciseTest { volatile Boolean executeInTurn = true; public synchronized void subTask(int times) throws Exception { while(! executeInTurn){ this.wait(); } for(int i = 1; i