GCD first, Brief introduction 1. What is GCD?
The full name is Grand Central Dispatch, which translates as "the backbone scheduler"
Pure C language, provides a lot of powerful functions
Advantages of 2.GCD
GCD is Apple's solution for multi-core parallel computing
[52 Effective ways to write high-quality iOS code] (10) Grand Central Dispatch (GCD)Reference book: "Effective Objective-c 2.0", "English" Matt GallowaySneak Peek41. Multi-use dispatch queue, less use of synchronous lock42. Multi-use GCD, less use Performselector series method43. Mastering the time of GCD and Operation queue44. Perform tasks based on system resou
Multithreading Introduction:For any iOS app, when the program is running, a main thread (Mainthread) is created by default, and the main thread is designed to handle the operations of Uikit objects, such as display and update of interfaces, actions triggered by user events, and so on. (Remember this, all UI-related operations are done in the main thread)For an app, there is a need to introduce multiple threads, largely because some operations are time-consuming, such as sending a network request
1, GCD Introduction:
?了解: GCD is all called "Grand Central Dispatch", pure C language, GCD provides a lot of powerful functions, GCD all the functions are contained in the Libdispatch library.
1-1, the advantage of using GCD:
?了解: 1,
recommended to use a weak pointer reference before using it in a code block (closure). In OC __weak __typeof (*self) ws = Self; In Swift, declare within the closure [unowned Self] Other than thatGCD also has some advanced usage, such as having 2 threads in the background executing in parallel, and then summarizing the execution results after 2 threads have finished. This can be achieved with Dispatch_group, Dispatch_group_async, and Dispatch_group_notify, as shown in the following example: disp
and sequential [same serial synchronization] is performed# Parallel asynchronous execution results: new multiple threads are created , operations are executed out of order (there is, error prone!) If there are other tasks before the queue, wait until the previous task is completed.Scene: does not affect the main thread, do not need to order the operation of the line! # parallel synchronization is performed before asynchronous results are performed: The asynchronous execution is not performed u
Program requirements: Read into the user input of the two integers K1 and K2 (K2>K1), and then output K1 and K2 gcd.
Reference program:
Import Java.util.Scanner;
public class P02 {public
static void Main (String arg[])
{
int k1,k2;
k1=0;
k2=0;
while (K1>=K2)
{
Scanner scan=new Scanner (system.in);
SYSTEM.OUT.PRINTLN ("Please input K1");
K1=scan.nextint ();
SYSTEM.OUT.PRINTLN ("Please input K2");
K2=scan.nex
iOS Development Multithreading Chapter-GCD IntroductionFirst, Brief introduction1. What is GCD?The full name is Grand Central Dispatch, which translates as "the backbone scheduler"Pure C language, provides a lot of powerful functionsAdvantages of 2.GCDGCD is Apple's solution for multi-core parallel computingGCD will automatically take advantage of more CPU cores (such as dual-core, quad- Core)
iOS Development Multithreading Chapter-GCD IntroductionFirst, Brief introduction1. What is GCD?The full name is Grand Central Dispatch, which translates as "the backbone scheduler"Pure C language, provides a lot of powerful functionsAdvantages of 2.GCDGCD is Apple's solution for multi-core parallel computingGCD will automatically take advantage of more CPU cores (such as dual-core, quad-core)
iOS Development Multithreading Chapter-GCD IntroductionFirst, Brief introduction1. What is GCD?The full name is Grand Central Dispatch, which translates as "the backbone scheduler"Pure C language, provides a lot of powerful functionsAdvantages of 2.GCDGCD is Apple's solution for multi-core parallel computingGCD will automatically take advantage of more CPU cores (such as dual-core, quad-core)
iOS Development Multithreading Chapter-GCD IntroductionFirst, Brief introduction1. What is GCD?The full name is Grand Central Dispatch, which translates as "the backbone scheduler"Pure C language, provides a lot of powerful functionsAdvantages of 2.GCDGCD is Apple's solution for multi-core parallel computingGCD will automatically take advantage of more CPU cores (such as dual-core, quad-core)
Gcd () --- indicates the maximum common number. The common method is Euclidean algorithm.
Ex_gcd () --- Extended Euclidean Algorithm
Definition 1: A and B are two integers not all 0, that is, the maximum common divisor of A and B is the maximum common divisor of A and B, and gcd (A, B) is used).
Definition 2: A and B are two non-0 integers. The smallest of the Public multiples of A and B is the smallest pub
iOS Development Multithreading Chapter-GCD IntroductionFirst, Brief introduction1. What is GCD?Full name is Grand Central DispatchPure C language, provides a lot of powerful functionsAdvantages of 2.GCDGCD is Apple's solution for multi-core parallel computingGCD will automatically take advantage of more CPU cores (such as dual-core, quad-core)GCD automatically ma
Cat Share, must boutiqueOriginal articles, welcome reprint. Reprint Please specify: Sanayu's BlogAddress: http://blog.csdn.net/u013357243?viewmode=contentsGCD Brief Introduction 1. What is GCD?The full name is Grand Central Dispatch, which translates as "the backbone scheduler"Pure C language, provides a lot of powerful functionsAdvantages of 2.GCDGCD is Apple's solution for multi-core parallel computingGCD will automatically take advantage of more CP
Ext.: http://www.cnblogs.com/wendingding/p/3806821.htmlFirst, Brief introduction1. What is GCD?The full name is Grand Central Dispatch, which translates as "the backbone scheduler"Pure C language, provides a lot of powerful functionsAdvantages of 2.GCDGCD is Apple's solution for multi-core parallel computingGCD will automatically take advantage of more CPU cores (such as dual-core, quad-core)GCD automatical
The following snippet is copied from the book (structure and interpretation of computer programs 1.2.5)
-----------------------------------------------
The greatest common divisor (GCD) of two integers A and B is defined to be the largest integer that divides both A and B with no remainder.The idea of the algorithm is based on the observation that, if R is the remainder when a is divided by B, then the common divisors of A and B are precisely the same
Calculate the maximum common divisor of two numbers A and B. We can think of enumerating each positive integer from [1, min (A, B:
#include
However, when a and B are large, this algorithm is not fast enough. There are faster and more elegant algorithms.
First, a theorem is given:
Gcd (a, B) = gcd (B, A-B) (a> = B)
Proof:
Set gcd (a, B) = M (M> = 1)
Then a
First, Brief introduction1. What is GCD?The full name is Grand Central Dispatch, which translates as "the backbone scheduler"Pure C language, provides a lot of powerful functionsAdvantages of 2.GCDGCD is Apple's solution for multi-core parallel computingGCD will automatically take advantage of more CPU cores (such as dual-core, quad-core)GCD automatically manages the life cycle of threads (create threads, s
Http://www.cnblogs.com/wendingding/p/3806821.htmlFirst, Brief introduction1. What is GCD?The full name is Grand Central Dispatch, which translates as "the backbone scheduler"Pure C language, provides a lot of powerful functionsAdvantages of 2.GCDGCD is Apple's solution for multi-core parallel computingGCD will automatically take advantage of more CPU cores (such as dual-core, quad-core)GCD automatically man
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.