Simultaneous accesses to 0x1c5a674c8, but modification requires exclusive access.
錯誤環境:
計時器計算,time是一個自定義結構體。
func countTimeWithConstantTime(time:timeStruct){
self.currentTime = time
timer.scheduleRepeating(wallDeadline: DispatchWallTime.now(), interval: 1.0)
timer.setEventHandler {
// let second = self.currentTime?.second
self.currentTime?.second = (self.currentTime?.second)! - 1
NVRLOG(self.currentTime?.second)
}
timer.resume()
}
錯誤分析:
報錯如標題,錯誤主要是在這一句
self.currentTime?.second = (self.currentTime?.second)! - 1
這是一個常規操作,如果計算的是基本資料型別,必然不會報錯。
現在currentTime是一個結構體,存在記憶體裡。進行計算的時候都會進行IO(讀寫)操作,這樣的話執行緒就不安全了,就是最開始學習的資源搶奪問題。
錯誤解決:
let second = self.currentTime?.second
self.currentTime?.second = second! - 1
這樣每次都是一個賦值,然後再從新賦值回去
相關文章
- sourcemaps and persistent modification in chromeChrome
- Dynamic Modification of SGA_TARGET (103)
- [Rust] Dealing with Vec modificationRust
- cannot mount database in EXCLUSIVE modeDatabase
- Oracle startup mount exclusive作用Oracle
- LoadRunner中Concurrent與Simultaneous的區別
- 啟用oracle table rowdependencies trace row modificationOracle
- innobackupex: Error: --decompress requires qpressErrorUI
- Exclusive access could not be obtained because the database is in useAIDatabase
- SAP QM Dynamic Modification Rule (動態修改規則)
- IAR中出現the order of volatile accesses is undefined in this statement的解決辦法Undefined
- oracle的exclusive和restricted啟動方式OracleREST
- Oracle blocking issue with lock table in exclusive modeOracleBloC
- 【C++】requires關鍵字簡介C++UI
- iOS signing for "***" requires a development team.iOSUIdev
- YouCompleteMe unavailable : requires Vim 7.4.143AIUI
- struct.error: 'h' format requires -32768 number 32767StructErrorORMUI
- Retroactive Billing – VFRB Modification to add credit/debit line
- WSL (Windows Subsystem for Linux) 的 VSLAM (Visual Simultaneous Localization and Mapping) 道路WindowsLinuxSLAMAPP
- VMware: ESXi requires the Execute Disable/No Execute CPU feature to be enabledUI
- ORA-01679: database must be mounted EXCLUSIVE and not open to activateDatabase
- 【故障-ORACLE】_NEXT_OBJE Exclusive鎖問題分析OracleOBJ
- HDU 3234 Exclusive-OR 擴充套件並查集套件並查集
- 使用View modification擴充套件SAP Fiori應用的一個案例View套件
- flutter doctor 時 提示 Flutter requires Android SDK 28 and ...【flutter】FlutterUIAndroid
- IE報vuex requires a Promise polyfill in this browser問題解決VueUIPromise
- ORA-01102: cannot mount database in EXCLUSIVE modeDatabase
- ORA-01102 cannot mount database in EXCLUSIVE modeDatabase
- 【ASM】ORA-15283: ASM operation requires compatible...ASMUI
- Determining whether an object requires reorganization MVS DB2ObjectUIDB2
- [20190416]exclusive latch測試指令碼.txt指令碼
- [Oracle] ORA-01102: cannot mount database in EXCLUSIVE modeOracleDatabase
- Parallel DML和append將在表上產生exclusive lockParallelAPP
- 論文解讀(DCN)《Towards K-means-friendly Spaces: Simultaneous Deep Learning and Clustering》
- this kernel requires an x86-64 cpu,but only detected an i686 cpuUI
- Uncaught Error: Bootstrap‘s JavaScript requires jQuery報錯問題解決ErrorbootJavaScriptUIjQuery
- bug solved | This experimental syntax requires enabling xxxUI
- How to Start 11gR2 Grid Infrastrucure in Exclusive Mode (Doc ID 1364971.1)AST