Last active
April 7, 2021 13:02
-
-
Save elnaqah/cc83c4bba13d9fa908e6a477f8366811 to your computer and use it in GitHub Desktop.
AsyncTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func execute(_ block: @escaping ()-> Void) { | |
block() | |
} | |
print("A") | |
execute { | |
print("B") | |
} | |
print("C") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func execute(_ block: @escaping ()-> Void) { | |
DispatchQueue.global().async { | |
block() | |
} | |
} | |
print("A") | |
execute { | |
print("B") | |
} | |
print("C") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func execute(_ block: @escaping ()-> Void) { | |
DispatchQueue.global().async { | |
block() | |
} | |
sleep(1) | |
} | |
print("A") | |
execute { | |
print("B") | |
} | |
print("C") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment