Weaving java.util.concurrent API using AspectJ

I stopped using AspectJ long back because we were not really coding aspects because it required an enormous amount of effort to train others. But recently I wrote this to weave into java.util.concurrent libraries to try to explore how the ForkJoin library works. Even though the code works I thought it is not a recommended way to weave into libraries dealing with concurrency written by experts. I pulled  the source and created a custom JAR and used -Xbootclasspath to make it work.

 

@Aspect
public class ForkJoinProjector {

	
	
    @Pointcut( "execution ( int java.util.concurrent.ForkJoinPool.registerWorker(java.util.concurrent.ForkJoinWorkerThread)) &&" +
			                " args(thread) &&" +
			                " target(pool)" )
    public void buildQueues( ForkJoinWorkerThread thread,
	                     ForkJoinPool pool){}
	
    @After("buildQueues( thread,pool)")
    public void build( ForkJoinWorkerThread thread,
    		           ForkJoinPool pool ) {
    	System.out.println( "ID " + thread.getId() + " Name " + thread.getName() );
    }


}

The Alan Turing Year

Image

I am watching the UEFA match between Poland and Greece and ruing the lack of professional ethics in the project management community and the great divide that exists between them and the technical team and I came across The Alan Turing Year. There is a flood of information here.

Rising stars or shooting stars

I have lamented in the past about organization structures in India that promote people to dizzying heights in a short span of time. These people are the ‘rising stars’ and they never gain expertise in any field. They pick a plum technical project to work on so that the next appraisal process favors them not because they are experts but because they are part of a highly visible team that boosted the financial success of the firm.

This is from ‘The Five stages of Capacity Planning’ by H Pat Artis

“Because capacity planning in this stage is a high visibility special project, it is often assigned to rising stars who will have long since been promoted by the time of the next planning cycle occurs.”

These rising stars are shooting stars who do not continue as technical leads and a newer crop of junior people take their place leading to standards that fall precipitously.

Rounding decimal digits

Price in Decimal digits is difficult to pay if your currency does not have low-value coins in circulation. So decimal digits might have to be rounded to the nearest value so that a figure like 0.56 can be paid. java.Math has MathContext and RoundingMode to round decimal digits.

So there is a precision that we specify. In the following code the precision is ‘1’ which means that .5625 is rounded to .6. We have rounded to 1 digit and the precision is lost but we ensure that the digits are either 0.5 or 0.6 depending on which is the nearest.

BigDecimal tax = new BigDecimal( 0.5625,
			new MathContext( 1,
 				RoundingMode.HALF_UP));

Output : 0.6

BigDecimal tax2 = new BigDecimal( 0.5325,
			new MathContext( 1,
				RoundingMode.HALF_UP));

Output : 0.5

BigDecimal tax2 = new BigDecimal( 0.5525,
			new MathContext( 1,
				RoundingMode.HALF_UP));

Output : 0.6 ( 0.55 is equidistant from 0.5 and 0.6. So it is rounded up to 0.6 )