Nikky
09/02/2018, 11:24 AMval targetFiles = Collections.synchronizedMap(mutableMapOf<String, File>())
val features = Collections.synchronizedList(mutableListOf<SKFeatureComposite>())
val jobs = mutableListOf<Job>()
for(...) {
jobs += launch {
//do work here
targetFile[id] = someFIle
if(feature != null) {
features += feature
}
}
}
jobs.forEach { it.join() }
is there cleaner ways to handle collecting data that lets me juggle less mutable collections ?Dominaezzz
09/02/2018, 11:30 AMasync
instead of launch
, then return the feature
, someFile
and id
. Then collect the results in the forEach
. To avoid the synchronization when using those collections.Nikky
09/02/2018, 11:33 AM.map {}
Dominaezzz
09/02/2018, 11:34 AMChannel
.Nikky
09/02/2018, 11:36 AMDominaezzz
09/02/2018, 11:37 AMNikky
09/02/2018, 11:40 AMDominaezzz
09/02/2018, 11:40 AMNikky
09/02/2018, 11:49 AMDominaezzz
09/02/2018, 12:44 PMDaniel Tam
09/02/2018, 2:12 PMNikky
09/02/2018, 4:09 PM