https://kotlinlang.org logo
g

gbm

03/15/2017, 1:28 PM
Copy code
fun task(start: Int, end: Int) {
            println("Start: $start; End: $end")
            for (i in start until end) distances[i] = Distance(i, euclideanDist(dataSet[i], example))
            latch.countDown()
        }

        for (i in 1..cores) {
            val start = startIndex
            val end = endIndex
            pool.execute { task(start, end) }
            startIndex = endIndex
            endIndex = if (i < cores - 1) endIndex + length else dataSet.size
        }