Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement a multithreading

Shulou Source: shulou.com Published: 2022-06-03 15:17:26 11月14日 Update

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

Tags: Threads loops traditions programs tests tasks content skills knowledge runs concise concise that is articles methods more articles industries information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft MySQL Linux vpn Shulou Technology