Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let calc (func:double -> double) (l,r, step : double) threadNumber:int =
- let n = (r-l)/double threadNumber
- let res = ref 0.0
- let threadArray = Array.init threadNumber ( fun x ->
- new Thread(ThreadStart(fun _ ->
- let threadRes = squareOnRange (func) (l+double x*n) (l+(double x+1.0)*n) step
- Monitor.Enter(res)
- res := !res + threadRes
- Monitor.Enter(res)
- )
- ))
- for x in threadArray do
- x.Start()
- for x in threadArray do
- x.Join()
- res.Value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement