Basic concepts of thread

What is a process? What is a thread Process: simple explanation, an application on the computer hard disk, such as QQ Exe, when it runs, is called a process. Thread: the smallest execution unit in a process is called a thread. Several ways of creating process 1. Inherit the Thread class and override the run() method 2. Implement the Runnable in ...

Posted by lill77 on Wed, 25 May 2022 15:54:58 +0300

The teacher has sent something, you have to queue up to receive it, Java synchronized keyword

When I was a child, when the teacher sent something, he asked us to line up one by one not to grab it, or we would get spanked. This scenario of multiple people queuing up to receive things is very similar to the scenario in which multiple threads access shared resources in programming. Today we combine the Java synchronized keyword to explain. ...

Posted by eastcoastdubs on Tue, 24 May 2022 03:06:35 +0300

Thread class of multithreading series

In the last article Multithreading Foundation , in this article, let's learn the Thread class in C# inside. The Thread class is in net framework1. API introduced in version 0. If you are not clear about the concept of Thread, please read my last article: Multithreading series (I), multithreading Foundation In this article, the method code of st ...

Posted by TAViX on Sun, 22 May 2022 10:09:00 +0300

​JDK1.8 new feature: still writing null pointer check code repeatedly? Use Optional now

1. Foreword As a Java programmer, whether a novice or a veteran expert, he must have encountered all kinds of abnormal errors. In a foreign article, the ranking list of exception types is counted, as shown in the following figure: Yes, you're right. NullPointerException tops the list. Charles Antony Richard Hoare, the inventor of Null Referen ...

Posted by habs20 on Sat, 21 May 2022 10:20:38 +0300

Java multithreading (with exercises and partial parsing)

Java multithreading and parallel programming 1, Basic knowledge points 1. Thread concept (understand) Program: represents a static object. It is a file containing instructions and data, which is stored on disk or other storage devices Process: represents a dynamic object. It is an execution process of a program. It exists in the memory ...

Posted by Lord Sauron on Sat, 21 May 2022 02:19:26 +0300

Java multi-threading ~ implements the singleton mode in two modes: "hungry man" and "lazy man"

content What is the singleton pattern? How to implement the singleton pattern through code? hungry man mode lazy mode Single thread version Multithreaded version double check method What is the singleton pattern? The singleton pattern is a type of design pattern. The singleton pattern means that when a class is provided for use else ...

Posted by mikeatrpi on Fri, 20 May 2022 22:24:49 +0300

threading module other classes

Lock When reading and writing data globally, if atomic operations cannot be guaranteed, it is easy to pollute the data. Such as: import threading import time from threading import Lock l = [0] def func(): num = l[0] time.sleep(0.001) l[0] = num + 1 threads = [] if __name__ == '__main__': for i in range(100): ...

Posted by Wynder on Thu, 19 May 2022 05:28:58 +0300

Design mode - eight different implementations of single case mode [JAVA] and single case question sorting - interview necessary - super detailed

Design mode - single case mode - eight different implementations [JAVA] and single case problem sorting - necessary for interview - super detailed Introduction to singleton mode the singleton pattern is a software design pattern that restricts the instantiation of a class to one "single" instance. It can be simply understood as: a class ca ...

Posted by SalokinX on Mon, 16 May 2022 21:13:29 +0300

Java thread pool must know and know

Java thread pool must know and know To know why it is, we should know why it is. In the process of using thread pool, do you understand why we should do this and how to configure thread pool to have better effect? Why should thread pool be used Thread pool is actually a way of using multithreading. In terms of design, it is a production c ...

Posted by beanfair on Sun, 15 May 2022 23:50:25 +0300

C + + thread class destruct deadlock problem

1, Foreword This paper will introduce a case that the main thread actively delete s the sub thread object, resulting in the main thread jamming (infinite waiting); 2, Cited examples 1. Case description 1) The implementation includes a main thread and a sub thread; 2) The main thread is responsible for starting the child thread and dest ...

Posted by asy1mpo on Fri, 13 May 2022 15:36:10 +0300