Through the previous two-thread understanding of the summary, their understanding of the thread gradually deepened, carding clear up ...
Usually when using the thread, it is to use the execution of the column, the way the execution, the execution of tasks,
Now start a new round of deep
3.1. 1 synchronous + Serial
-(void) syncserialqueue{ dispatch_queue_t queue = dispatch_queue_create ("Test", dispatch_queue_serial); NSLog (@ "Sync + serial start:::%@", [Nsthread CurrentThread]); //Add Task 1 for (int i = 0; i < 3; i++) { NSLog (@ "sync + serial index%d:::%@", I,[nsthread CurrentThread]); } }); Dispatch_sync (queue, ^{ //Add Task 2for (int i = ten; i <; i++) { NSLog (@ "Sync + serial I Ndex%d:::%@ ", I,[nsthread CurrentThread]); } ); NSLog (@ "Sync + serial end:::%@", [Nsthread CurrentThread]);}
Results of execution:::
2017-12-21 09:10:16.725075+0800 deadthread[10455:3327379] Sync + serial start:::<nsthread:0x60800006b4c0>{number = 1, n ame = main} 2017-12-21 09:10:16.725222+0800 deadthread[10455:3327379] Sync + serial index 0::: <NSTHREAD:0X60800006B4C0&G T {Number = 1, name = main}2017-12-21 09:10:16.725339+0800 deadthread[10455:3327379] Sync + serial index 1::: <nsthread:0x6 0800006b4c0>{number = 1, name = main}2017-12-21 09:10:16.725530+0800 deadthread[10455:3327379] Sync + serial index 2::: &L T Nsthread:0x60800006b4c0>{number = 1, name = main}2017-12-21 09:10:16.725615+0800 deadthread[10455:3327379] Sync + serial I Ndex::: <nsthread:0x60800006b4c0>{number = 1, name = main}2017-12-21 09:10:16.725765+0800 DeadThread[10455:332 7379] Sync + serial index::: <nsthread:0x60800006b4c0>{number = 1, name = main}2017-12-21 09:10:16.725821+0800 Dead THREAD[10455:3327379] Sync + serial index::: <nsthread:0x60800006b4c0>{number = 1, name = Main}2017-12-21 09:10:16. 725870+0800 Deadthread[10,455:3,327,379] sync + serial end::: <nsthread:0x60800006b4c0>{number = 1, name = main}
Summary results::
1. Synchronization: Executing in the current thread, not opening new threads, task order execution
2. Serial: Added task sequence, sequential execution
Icon::::
3.1.2 Synchronous + Parallel
-(void) syncconcurrentqueue{ dispatch_queue_t queue = dispatch_queue_create ("Test", dispatch_queue_concurrent); NSLog (@ "Synchronous + parallel start:::%@", [Nsthread CurrentThread]); Dispatch_sync (queue, ^{for (int i = 0; i < 3; i++) { NSLog (@ "Sync + parallel index%d:::%@", I,[nsthread Currentt Hread]); } ); Dispatch_sync (queue, ^{for (int i = ten; i <; i++) { NSLog (@ "Sync + parallel index%d:::%@", I,[nsthread Curr Entthread]); } ); NSLog (@ "Sync + parallel end:::%@", [Nsthread CurrentThread]);}
Results of execution:::
2017-12-21 09:37:05.376797+0800 deadthread[10595:3430843] Synchronization + Parallel Start:::<nsthread:0x6040000759c0>{number = 1, name = main} 2017-12-21 09:37:05.376915+0800 deadthread[10595:3430843] Sync + parallel index 0::: <nsthread:0x6040000759c0& Gt {Number = 1, name = main}2017-12-21 09:37:05.377000+0800 deadthread[10595:3430843] Sync + parallel index 1::: <nsthread:0x6 040000759c0>{number = 1, name = main}2017-12-21 09:37:05.377101+0800 deadthread[10595:3430843] Sync + parallel index 2::: &L T Nsthread:0x6040000759c0>{number = 1, name = main}2017-12-21 09:37:05.377262+0800 deadthread[10595:3430843] Synchronous + parallel in Dex::: <nsthread:0x6040000759c0>{number = 1, name = main}2017-12-21 09:37:05.377372+0800 deadthread[10595:3430 843] Sync + parallel Index One::: <nsthread:0x6040000759c0>{number = 1, name = main}2017-12-21 09:37:05.377440+0800 deadth READ[10595:3430843] Sync + parallel index::: <nsthread:0x6040000759c0>{number = 1, name = Main}2017-12-21 09:37:05.377 514+0800 deadthread[10595:3,430,843] Sync + parallel End::: <nsthread:0x6040000759c0>{number = 1, name = main}
Summary results::
1. Synchronization: Executing in the current thread, not opening new threads, task order execution
2. Parallelism: Added tasks are not ordered
Icon::::
3.2.1 Asynchronous + Serial
-(void) asyncserialqueue{ dispatch_queue_t queue = dispatch_queue_create ("Test", dispatch_queue_serial); NSLog (@ "async + serial start:::%@", [Nsthread CurrentThread]); Dispatch_async (queue, ^{for (int i = 0; i < 3; i++) { NSLog (@ "async + Serial Index%d:::%@", I,[nsthread current Thread]); } ); Dispatch_async (queue, ^{for (int i = ten; i <; i++) { NSLog (@ "async + Serial Index%d:::%@", I,[nsthread cur Rentthread]); } ); NSLog (@ "async + serial end:::%@", [Nsthread CurrentThread]);}
Execution results:::
2017-12-21 09:43:04.903888+0800 deadthread[10647:3468013] Async + Serial Start:::<nsthread:0x60c0000654c0>{number = 1, name = main} 2017-12-21 09:43:04.904032+0800 deadthread[10647:3468013] Async + serial End::: <nsthread:0x60c0000654c0>{nu mber = 1, name = main}2017-12-21 09:43:04.904056+0800 deadthread[10647:3468266] Async + Serial index 0::: <nsthread:0x6040 00074580>{number = 3, name = (null)}2017-12-21 09:43:04.904127+0800 deadthread[10647:3468266] Async + Serial index 1::: < ; Nsthread:0x604000074580>{number = 3, name = (null)}2017-12-21 09:43:04.904180+0800 deadthread[10647:3468266] Async + serial Index 2::: <nsthread:0x604000074580>{number = 3, name = (null)}2017-12-21 09:43:04.904370+0800 Deadthread[10647:3 468266] Async + Serial index::: <nsthread:0x604000074580>{number = 3, name = (null)}2017-12-21 09:43:04.904534+0800 DEADTHREAD[10647:3468266] Async + Serial Index One::: <nsthread:0x604000074580>{number = 3, name = (null)}2017-12-21 09: 43:04.904603+0800 DeadthreAD[10647:3468266] Async + Serial index::: <nsthread:0x604000074580>{number = 3, name = (NULL)}
Summary results::
1. Async: Open a new thread without affecting the current thread;
2. Serial: Add task order, order execution
3.2.2 Asynchronous + Parallel
-(void) asyncconcurrentqueue{ dispatch_queue_t queue = dispatch_queue_create ("Test", dispatch_queue_concurrent) ; NSLog (@ "Asynchronous + parallel start:::%@", [Nsthread CurrentThread]); Dispatch_async (queue, ^{for (int i = 0; i < 3; i++) { NSLog (@ "asynchronous + Parallel index%d:::%@", I,[nsthread current Thread]); } ); Dispatch_async (queue, ^{for (int i = ten; i <; i++) { NSLog (@ "asynchronous + Parallel index%d:::%@", I,[nsthread cur Rentthread]); } ); NSLog (@ "Sync + parallel end:::%@", [Nsthread CurrentThread]);}
Results of execution:::
2017-12-21 09:50:40.207852+0800 deadthread[10727:3517966] Async + Parallel Start:::<nsthread:0x60c00006d880>{number = 1, name = main} 2017-12-21 09:50:40.208038+0800 deadthread[10727:3517966] Sync + parallel End::: <nsthread:0x60c00006d880>{nu mber = 1, name = main}2017-12-21 09:50:40.208045+0800 deadthread[10727:3518055] Async + Parallel Index::: <nsthread:0x6040 0006f3c0>{number = 3, name = (null)}2017-12-21 09:50:40.208066+0800 deadthread[10727:3518052] Async + Parallel index 0::: < ; Nsthread:0x600000075700>{number = 4, name = (null)}2017-12-21 09:50:40.208139+0800 deadthread[10727:3518055] Async + Parallel Index one::: <nsthread:0x60400006f3c0>{number = 3, name = (null)}2017-12-21 09:50:40.208197+0800 deadthread[10727: 3518052] Async + Parallel index 1::: <nsthread:0x600000075700>{number = 4, name = (null)}2017-12-21 09:50:40.208327+0800 DEADTHREAD[10727:3518055] Asynchronous + Parallel Index::: <nsthread:0x60400006f3c0>{number = 3, name = (null)}2017-12-21 09:5 0:40.208361+0800 Deadthread[10,727:3,518,052] Async + Parallel index 2::: <nsthread:0x600000075700>{number = 4, name = (NULL)}
Summary results::::
1. Async: Turn on threading capability;
2. Parallel: The task queue is not arranged in sequence, simultaneously executes;
3. Number of threads opened: depending on the number of tasks added
Icon:::
IOS Multi-Threading Simple comprehension (3) Execution mode + execution of a combination of columns