                 print("2 j=\(j) \(Thread.current)")
             }
         }
-        print("3 \(Thread.current)")
-        
-        /*
-         并发执行。 不在主线程
-         开启新线程
-         
-         1 <NSThread: 0x2800b2940>{number = 1, name = main}
-         3 <NSThread: 0x2800b2940>{number = 1, name = main}
-         2 i=0 <NSThread: 0x2800ece00>{number = 6, name = (null)}
-         2 i=1 <NSThread: 0x2800ece00>{number = 6, name = (null)}
-         2 i=2 <NSThread: 0x2800ece00>{number = 6, name = (null)}
-         2 i=3 <NSThread: 0x2800ece00>{number = 6, name = (null)}
-         2 i=4 <NSThread: 0x2800ece00>{number = 6, name = (null)}
-         2 i=5 <NSThread: 0x2800ece00>{number = 6, name = (null)}
-         2 j=0 <NSThread: 0x2800ece00>{number = 6, name = (null)}
-         2 j=1 <NSThread: 0x2800ece00>{number = 6, name = (null)}
-         2 j=2 <NSThread: 0x2800ece00>{number = 6, name = (null)}
-         2 j=3 <NSThread: 0x2800ece00>{number = 6, name = (null)}
-         2 j=4 <NSThread: 0x2800ece00>{number = 6, name = (null)}
-         2 j=5 <NSThread: 0x2800ece00>{number = 6, name = (null)}
+        
+        for _ in 0...20 {
+            print("33333333333333 \(Thread.current)")
+        }
+       
+        
+        /*
+         并发执行， 不在主线程
+         开启新线程  （异步执行2不一定在最后才执行，只不过异步执行需要时间，一般慢于主线程的打印操作）
+         
+         1 <NSThread: 0x2802cc740>{number = 1, name = main}
+         2 i=0 <NSThread: 0x280280440>{number = 6, name = (null)}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         2 j=0 <NSThread: 0x2802897c0>{number = 7, name = (null)}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         2 j=1 <NSThread: 0x2802897c0>{number = 7, name = (null)}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         2 i=1 <NSThread: 0x280280440>{number = 6, name = (null)}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         2 j=2 <NSThread: 0x2802897c0>{number = 7, name = (null)}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         2 i=2 <NSThread: 0x280280440>{number = 6, name = (null)}
+         2 j=3 <NSThread: 0x2802897c0>{number = 7, name = (null)}
+         2 i=3 <NSThread: 0x280280440>{number = 6, name = (null)}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         2 i=4 <NSThread: 0x280280440>{number = 6, name = (null)}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         2 i=5 <NSThread: 0x280280440>{number = 6, name = (null)}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         2 j=4 <NSThread: 0x2802897c0>{number = 7, name = (null)}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         2 j=5 <NSThread: 0x2802897c0>{number = 7, name = (null)}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+         33333333333333 <NSThread: 0x2802cc740>{number = 1, name = main}
+
+         
+         */
+    }
+    
+    @objc func concurrentQueue_Sync_Async() {
+        
+        print("1 \(Thread.current)")
+        let queue = DispatchQueue.global(priority: .default)
+        queue.sync {
+            print("2  \(Thread.current)")
+        }
+        queue.async {
+            print("3  \(Thread.current)")
+        }
+        print("4  \(Thread.current)")
+        queue.async {
+            print("5  \(Thread.current)")
+        }
+        queue.sync {
+            print("6  \(Thread.current)")
+        }
+        print("7  \(Thread.current)")
+        
+        /*
+         答案可以为多种结果， 但是 1 2 4 6 7 的顺序是肯定的， 3和5在另外一个子线程异步执行，时间不可控
+         1, 2, 4, 6, 7, 3, 5
+         1, 2, 4, 6, 3, 7, 5
+         1, 2, 4, 3, 6, 5, 7
+         1, 2, 4, 3, 5, 6, 7
+
+         打印结果：
+         1 <NSThread: 0x280690680>{number = 1, name = main}
+         2  <NSThread: 0x280690680>{number = 1, name = main}
+         4  <NSThread: 0x280690680>{number = 1, name = main}
+         6  <NSThread: 0x280690680>{number = 1, name = main}
+         3  <NSThread: 0x2806d4f00>{number = 7, name = (null)}
+         7  <NSThread: 0x280690680>{number = 1, name = main}
+         5  <NSThread: 0x2806d4f00>{number = 7, name = (null)}
          
          */
     }

        print("1 \(Thread.current)")
        let queue = DispatchQueue.init(label: "serialQueueAsync")
        queue.async {
            for i in 0...5 {
                print("2 i=\(i) \(Thread.current)")
            }
        }
        queue.async {
            for j in 0...5 {
                print("2 j=\(j) \(Thread.current)")
            }
        }
        print("3 \(Thread.current)")
        
        /*
         并发执行。 不在主线程
         开启新线程
         
         1 <NSThread: 0x280466b00>{number = 1, name = main}

    @objc func concurrentQueueAsync() {
        
        print("1 \(Thread.current)")
        let queue = DispatchQueue.init(label: "concurrentQueueAsync", attributes: .concurrent)
        queue.async {
            for i in 0...5 {
                print("2 i=\(i) \(Thread.current)")   // i和j是并发打印，没有先后顺序
            }
        }
        queue.async {
            for j in 0...5 {
                print("2 j=\(j) \(Thread.current)")
            }
        }
        print("3 \(Thread.current)")
        
        /*
         并发执行， 不在主线程
         开启新线程
         
         1 <NSThread: 0x282520740>{number = 1, name = main}
         3 <NSThread: 0x282520740>{number = 1, name = main}
         2 i=0 <NSThread: 0x282527d00>{number = 4, name = (null)}
         2 i=1 <NSThread: 0x282527d00>{number = 4, name = (null)}
         2 i=2 <NSThread: 0x282527d00>{number = 4, name = (null)}
         2 j=0 <NSThread: 0x28256db00>{number = 7, name = (null)}
         2 i=3 <NSThread: 0x282527d00>{number = 4, name = (null)}
         2 i=4 <NSThread: 0x282527d00>{number = 4, name = (null)}
         2 i=5 <NSThread: 0x282527d00>{number = 4, name = (null)}
         2 j=1 <NSThread: 0x28256db00>{number = 7, name = (null)}
         2 j=2 <NSThread: 0x28256db00>{number = 7, name = (null)}
         2 j=3 <NSThread: 0x28256db00>{number = 7, name = (null)}
         2 j=4 <NSThread: 0x28256db00>{number = 7, name = (null)}
         2 j=5 <NSThread: 0x28256db00>{number = 7, name = (null)}
         
         
         问题： 以上的 3  一定在 2 之前执行吗？？ 答案： 不一定
         
         */
    }
    
    // 求证问题：3 一定在 2 之前执行吗？？ 答案： 不一定
    
    @objc func concurrentQueueAsync2() {
        
        print("1 \(Thread.current)")
        let queue = DispatchQueue.init(label: "concurrentQueueAsync2", attributes: .concurrent)
        queue.async {
            for i in 0...5 {
                print("2 i=\(i) \(Thread.current)")
