경쟁 상황 (Race Condition) 두개 이상의 Thread를 사용하면서, 동일한 메모리 접근 등으로 인해 발생할 수 있는 문제 아래 예제를 보시죠. var value = 777 func changeValue1() { sleep(2) value = 222 } func changeValue2() { sleep(2) value = 0 } queue.async { changeValue1() } queue.async { changeValue2() } print("(비동기)함수 실행값:", value) print에는 뭐가 찍힐까요 ? 777 이나와요. changeValue1,2 함수가 실행되고 기다리는동안 (sleep) 제일 아래 print 문이 실행되는거죠. 해결방법 (3가지) 1. TSan (Thread..
GCD란? Grand Central Dispatch의 약자로, 앱의 메인스레드 또는 백그라운드 스레드에서 작업 실행을 순차적 또는 동시에 관리하는 객체 입니다. Dispatch Queue 종류 Serial Dispatch Queue (Main Queue) - 순차적으로 작업을 실행 합니다. - UI와 관련된 작업은 모두 main Queue를 통해 수행 합니다. - MainQueue를 sync메소드로 동작시키면 Dead Lock 상태에 빠집니다. DispatchQueue.main.async { } Concurrent Dispatch Queue (Global Queue) - 동시에 작업을 실행 합니다. - UI를 제외한 작업에서 사용하며 Concurrent Queue에 해당합니다. - sync, async ..
- Total
- Today
- Yesterday
- 2023년 회고
- Swift Error Handling
- Swift 프로그래머스
- Swift RIBs
- Swift 내림차순
- swift protocol
- Swift Leetcode
- ios
- Swift while
- Swift init
- Swift
- Swift ModernRIBs
- 호텔리어 개발자
- swift reduce
- swift 고차함수
- 원티드 프리온보딩
- Swift joined()
- RIBs tutorial
- Uber Architecture
- Swift 프로퍼티
- swift function
- Swift final
- iOS GCD
- Class
- Swift joined
- iOS error
- Combine: Asynchronous Programming with Swift
- swift property
- Swift inout
- CS 네트워크
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |