addressalign-toparrow-leftarrow-leftarrow-right-10x10arrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcredit-cardcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1languagelaunch-new-window--smalllight-bulblightning-boltlinklocation-pinlockm-swarmSearchmailmediummessagesminusmobilemoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstar-shapestartickettrashtriangle-downtriangle-uptwitteruserwarningyahooyoutube

Re: [ljc] Java 8 executors, the denouement

From: Russel W.
Sent on: Thursday, March 27, 2014, 6:32 PM
On Thu,[masked] at 08:41 -0400, Kevin Wright wrote:
> 
> 
> Look ma, no mutation!
> 
> 
>         final double pi = 4.0d * delta * IntStream.range(0,
>         numberOfTasks).mapTo­Obj(i ->
>           CompletableFuture.su­pplyAsync(() ->
>             <stuff using taskId resulting in a double>
>           )
>         ).mapToDouble(Comple­tableFuture::join).s­um();

The explicit future are wrong in this approach. The "real thing" would
likely be:

final double pi = 4.0d * delta * IntStream.range(0, numberOfTasks).paral­lel().mapToDouble(
	<stuff to calculate a double>
).sum();      

Well that's the version I've had for a while.

-- 
Russel.
====================­====================­====================­=================
Dr Russel Winder      t: [masked]   voip: sip:[address removed]
41 Buckmaster Road    m: [masked]   xmpp: [address removed]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

People in this
group are also in: