pthreads :: concurrent_collections
Introduces thread-safe concurrent collectionscore :: union_find
union–find algorithm using an efficient disjoint-set data structure
# Simple example using threadpool
module threadpool_example is example
import threadpool
# Task printing "hello world" on standard output
class HWTask
super JoinTask
# Sleeping time
var sec: Int
# id
var id: Int
redef fun main do
print "Hello from {id}"
nanosleep(sec, 0)
print "World from {id}"
end
end
var tp = new ThreadPool
for i in 100.times do
var t = new HWTask(2.rand, i)
tp.execute(t)
end
nanosleep(20,10)
lib/pthreads/examples/threadpool_example.nit:15,1--42,16