Hi,
Is map/list in ThreadSafeMap thread safe? I have to store info in map/list for each thread, code:
Is map/list in ThreadSafeMap thread safe? I have to store info in map/list for each thread, code:
B4X:
'In main thread
Public tidInfoMap As Map
Public tidInfoList As Map
...
tidInfoMap=srvr.CreateThreadSafeMap '{threadid:{"tick":"...";"id":"..."}}
tidInfoList=srvr.CreateThreadSafeMap '{threadid:["1","2","3",...]}
'In the threads
threadid=Main.srvr.CurrentThreadIndex
'map
Dim m3 As Map =main.tidInfoMap.Get(threadid)
'update map
If m3.IsInitialized=False Then m3.Initialize
m3.Put("tick",datetime.now)
m3.Put("id",id)
'get data
dim dateticks as long= m3.get("tick")
'list
Dim listinfo As List =main.tidInfoList.Get(threadid)
'update list
listinfo.Add(DateTime.Now)
'get data in list
listinfo.get(0)
Last edited: