C + + Supplements-Multithreading: the introduction of multithreadingObjectiveMultithreading is an important part of programming. Multi-core era makes multithreading known as a possibility, obviously, one thing many people do, efficiency will certainly improve. Let's look at how multithreading is used in C language.BodyLet's look at an example first#define _crt_secure_no_warnings#include RunThree windows were ejected asynchronously, and the respective
C + + Supplements-Multithreading: The main thread synchronizes with child threadsPrefaceIn multithreaded programming, it is sometimes necessary to require the main thread to synchronize with the child thread.BodyProgram DemoThe following example illustrates the synchronization problem between the main thread and the child thread.Program Description:In the main thread, there is an integer variable count, initialized to 0. The main thread passes the add
C + + Supplements--the principle of virtual functionObjectiveC + + 's polymorphism relies on virtual functions to implement. If a class has virtual functions, each instance of the class maintains an address that points to the virtual function table. The virtual function table holds the addresses of all virtual functions in the class. Here we find the address of the virtual function table, get the address of each virtual function, and then call the vir
C + + supplements--malloc free vs. new DeletePrefaceIn c we often use malloc and free to dynamically allocate and release memory, which corresponds to new and delete in C + +. Here we are going to discuss their differences.Body1. Built-in typeDebug the same code to see the memory#include DebuggingThe same functionality uses new and delete to manipulate#include ModeFor built-in types, the effect is the same for both sets of operations.2. Class TypeCode
C + + supplements--positioning the new expressionPrefaceThe new expression, by default, opens up the memory to the heap area. Using the positional new expression, you can construct an object in the specified address area (stack, heap, static), which is akin to opening the memory to a specified area.Bodylocating the common form of the new expression
New (address) type;
New (address) type (initializers);
New (address) type[size];
Ne
What is a vitamin supplement?A vitamin supplement is a tablet or capsule that is naturally extracted or synthesized to ensure the daily intake of adequate vitamins in special groups. Special groups include: People with irregular diet and a single type of food that causes insufficient vitamin intake, and people with vitamin deficiency diagnosed.Classification of vitamin supplementsNatural Vitamin supplements: health care products made from natural food
C + + supplements--LAMBDA expression principlePrefaceLambda expressions are presented in the new C++11 standard. In lambda expressions, we focus on the use of it. Now let's talk about how it's implemented.Body1. Function ObjectsThe object of the class is combined with parentheses to show the general behavior of the function, which can be called a function object.#include RunThis example shows that the essence of a function object is to overload the fu
C + + Supplements--function overloadingPrefaceFunction overloading does not seem difficult, but there are still some issues worth noting. Here are some key words to start with:Body1. ScopeThere are several facts to be pointed out about scopes
The area enclosed in curly braces {} is in the same scope, with a common function body, for, if statement, and so on.
A variable with the same name cannot appear in the same scope, and if the functio
C + + Supplements-Multithreading: critical section resolves mutex for sub-threadsPrefaceIn order to solve the mutex problem of sub-threads, the Windows system presents the concept of critical segment or critical section (critical_section). It has four total of two operations: Initialize, destroy, enter, leave. They are defined in the header file synchapi.h.1. Initializing variablesVOID WINAPI InitializeCriticalSection (Lpcritical_section lpcriticalsec
.-Method parameter to arrayWe often see code like Array.prototype.slice.call (arguments) in some open-source frameworks,arguments is a default property within the method, an object type, Include parameter listsuch as0:PARAM1,1:PARAM2,....Length:n}This can be assigned to the Array.slice method by calling the Array.prototype.slice.call() method, since JS calls arrays and objects Array[index] and Object[index] The result is the same, so you can also use this method to enter an object that contains
; //newobj.i = this.i; //return NEWOBJ; //implementing Deep Replication-Mode 2: Serialization/deserializationBinaryFormatter BF =NewBinaryFormatter (); MemoryStream Ms=NewMemoryStream (); Bf. Serialize (MS, This); Ms. Position=0; returnBF. Deserialize (MS); } ...... } [Serializable] Public classA { Public stringMessage ="I am the original a"; }View Code
PS: generally inheritable types should avoid implementing the ICloneable interface , because doing so would force a
1. Class loadingBootstrap ClassLoader-Boot (also known as primitive) class loader, which is responsible for loading Java's core classes. Extension ClassLoader-the extension classloader, which is responsible for loading the class pack of the jar in the JRE's extended directory (Java_home/jre/lib/ext or specified by the Java.ext.dirs system properties). System ClassLoader-Systems (also known as applications) ClassLoader, which is responsible for loading-classpath or Java.class.path System Properti
ConstructorsSubclass code BlockSub-class constructors----------Parent Class code blockParent class ConstructorsSubclass code BlockSub-class constructors9.java garbage Collection relatedJava provides a system-level thread, the garbage collector thread. Used to track each allocated memory space. When the JVM is idle, automatically reclaims every memory that may be reclaimed, the GC is completely automatic and cannot be enforced. Programmers can only use System.GC () to recommend that the garbage
([]) # string, list, dictionaryB. Specific methodsCountIndexc. Nesting (elements cannot be modified)t = (11,22,33)t = (11,22,["Alex", {"K1": "V1"}]) e. Properties of tuples, non-modifiable, who cannot be modified tuples, son cannot change tuples, son can't change, grandson, ... organizing: General string, perform a function, generate a new content, the original content is unchanged list,tuple,dict, performing a function that changes itself
that the type can be used in the scope of the class.Member initialization syntax1, can only be used for constructors.2. A non-static const member must be initialized this way.3. Reference data members must be initialized like this.The format is as follows:Classname::classname (int N): Mem1 (n), mem2 (0), mem3 (null) { // Construct .... }After the colon, mem1,mem2,mem3 are data members that are classname, and the order of initialization is consistent with their order in the class declarat
(); } } catch (Interruptedexception e) { e.printstacktrace ();}} }public class Run {public static void Main (string[] args) throws interruptedexception { MyThread t = new Mythrea D (); T.start (); Thread.Sleep (+); If not, the state of T is runnable System.out.println ("T state in the Main method:" + t.getstate ());} }
The T state in the Main method: Waiting
The State enumeration value of the thread af
guarantees that myexception owns the source member returnMyexception.source; } } Public classClasst2whereR |class { PrivateT MyT; Public voidClear () {//T is a reference type and can be set to nullMyT =NULL; } } Public classClasst3whereT:struct { PrivateT MyT; Public Override stringToString () {//T is a value type and NullReferenceException exception does not occur returnmyt.tostring (); } }View CodeOnce a generic parameter has a prim
) enum.parse (typeof (color), "white");
Note: If the string does not correspond to the enumeration, an error occurs.
Enum e { }
struct Structure:
User-defined data type, struct type. A struct can contain constructors, constants, fields, methods, properties, indexers, and operators.
Structure is a value type and the address is assigned on the stack
Both structs and classes can inherit interfaces.
Structs cannot be integrated, classes can.
Structs do not have destructors, classes have.
st
(hidden method), and new overrides the base class with the same name method (the receive parameter is the same).
Terminating inheritance:
Terminates the inheritance identity sealed. The following code compiles an error and Class2 cannot inherit the enclosing class Class1
public sealed class Class1 {public virtual void Show (int i) {...} } public class Class2:class1 //{ //public override void Show (int a) // {...} //}
Call the base class constructor:
The
class, using the format of the IsMatch method:Regex.IsMatch (string to judge, regular expression)Example one, using the IsMatch method to determine whether the program meets the local telephone numberif input: 0530-12345678The result of the output is: 0530-12345678 is the telephone number of a placeTwo, replacement of regular expressionsTo replace a match in a string with a regular expression, pass the Replace method in the Regex class. A commonly used format is:Regex.Replace (the string to be
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.