February 2018
Intermediate to advanced
350 pages
7h 35m
English
The code dependency between threads is referred to as coupling. We should try to keep coupling as low as possible, to avoid complexity and make the code base easy to read and maintain. Now, what does that actually mean? Refer to the program with threading where we accessed and modified the someData value from two threads simultaneously. That can be called coupling, as both the threads were dependent on each other. For your reference, we copied the following code-snippet:
async(CommonPool) {
for(i in 11..20) {
myData.someData+=i
println("someData from 1st async ${myData.someData}")
delay(500)
}
}
async(CommonPool) {
for(i in 1..10) {
myData.someData++
println("someData from 2nd async ${myData.someData}")
delay(300)
}
}
In the ...
Read now
Unlock full access