[JSR] [JEP] Java Specification Requirement / Java Enhancement Proposal : 'Parallel OR' and 'Parallel AND'
matcdac at gmail.com
Wed Jul 24 12:19:00 UTC 2019
Hi David / All,
Earlier wanted to discuss just the implementation of 'OR operator', neither
'Conditional OR operator', nor 'Bitwise OR operator'
Same goes with 'AND operator'
Technically OR operator and AND operator are just binary operators, that's
I don't find it wrong considering there can be n operands, in an
expression, with either of the two operators or a combination of both,
where n >= 2
n can go nearby anything in powers of 10, it will take those many
sequential clock cycles, to actually resolve the expression
If you consider the same n as an expression of powers of 2, the same thing
can be done in parallel clubbed with divide and conquer, taking the same
number of clock cycles, but saving actual response time
This can be given as a input from console, or as a property, specifying
which implementation to use at runtime, sequential or parallel
But with the latter would lead to very frequent resource starvage, this
would need to be handled, to actually free the resources and give to pid or
ppid, heirarically, or based upon who is the callee, or who asked who to
wait, or some more other logic
All the threads parallelly evaluating the same expression, with either
operand, should be terminated and concluded as, when any thread results to:
'true' in case of OR
'false' in case of AND
An expression can have further sub-expressions; so an expression with
combination of both operands, will be considered as parent expression
Yes it does change the conventional implementation of OR operator, and AND
operator, in Java
So it would be better to have two new operators/symbols itself
We can go with the symbol |&& also in case of Parallel AND
Looking forward to hearing your thoughts
Best Wishes & Regards
On 22/06/2019 1:28 am, Prakhar Makhija wrote:
> Topic: OR operator represented by ||
That should be the subject of your email - not a reply to a digest.
> Query: The expression evaluation of the operands, of OR operator, does it
> happen in parallel, when Java code runs, in the current versions?
No, there is no parallel evaluation of anything in Java. It would be
wrong to do so in this case as:
"The conditional-or operator || operator is like | (§15.22.2), but
evaluates its righthand operand only if the value of its left-hand
operand is false."
More information about the core-libs-dev