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
這樣每次都是一個賦值,然後再從新賦值回去
相關文章
- [Rust] Dealing with Vec modificationRust
- Basic Steps to Create Dynamic Modification Rule
- [20190418]exclusive latch spin count.txt
- Retroactive Billing – VFRB Modification to add credit/debit line
- [20190416]exclusive latch測試指令碼.txt指令碼
- ORA-01102: cannot mount database in EXCLUSIVE modeDatabase
- WSL (Windows Subsystem for Linux) 的 VSLAM (Visual Simultaneous Localization and Mapping) 道路WindowsLinuxSLAMAPP
- bug solved | This experimental syntax requires enabling xxxUI
- SAP QM Dynamic Modification Rule (動態修改規則)
- IAR中出現the order of volatile accesses is undefined in this statement的解決辦法Undefined
- 【C++】requires關鍵字簡介C++UI
- [20190416]11g下那些latch是Exclusive的.txt
- struct.error: 'h' format requires -32768 number 32767StructErrorORMUI
- 事務傳播機制之REQUIRES_NEWUI
- flutter doctor 時 提示 Flutter requires Android SDK 28 and ...【flutter】FlutterUIAndroid
- 論文解讀(DCN)《Towards K-means-friendly Spaces: Simultaneous Deep Learning and Clustering》
- 使用View modification擴充套件SAP Fiori應用的一個案例View套件
- Requires: libc.so.6(GLIBC_2.14)(64bit)UI
- oracle ORA-01102: cannot mount database in EXCLUSIVE mode(無法起到獨佔模式)OracleDatabase模式
- 深入理解Java併發框架AQS系列(三):獨佔鎖(Exclusive Lock)Java框架AQS
- error: #error This file requires compiler and library support for the ISO C++ 2011 standard.ErrorUICompileC++
- Uncaught Error: Bootstrap‘s JavaScript requires jQuery報錯問題解決ErrorbootJavaScriptUIjQuery
- this kernel requires an x86-64 cpu,but only detected an i686 cpuUI
- 執行新增和修改操作報錯connection is read-only. Queries leading to data modification are not allowed
- [轉帖]Spring事務傳播屬性之REQUIRES_NEW用法SpringUI
- win10玩gta提示requires at least direct version 9.0修復方法Win10UIAST
- 使用註解 @requires 給 SAP CAP CDS 模型新增許可權控制UI模型
- ubuntu15 安裝nginx 報錯:the HTTP rewrite module requires the PCRE library.UbuntuNginxHTTPUI
- pytorch執行錯誤:RuntimeError: a leaf Variable that requires grad is being used in an in-place operationPyTorchErrorUI
- Oracle 12c DG備庫啟動報錯standby database requires recoveryOracleDatabaseUI
- anacond 或python3 報check_hostname requires server_hostname錯誤PythonUIServer
- vue搭建腳手架 出現問題Command vue init requires a global addon to be installed.VueUI
- 排錯./configure: error: the HTTP XSLT module requires the libxml2/libxslt libraries. You can either doErrorHTTPUIXML
- Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.的錯誤ErrorUI
- spring事務傳播的Propagation.REQUIRES_NEW以及NEVER MANDATORY驗證,及其失效的詭異問題SpringUI