Performing Fibonacci Calculations Synchronously

Method main (lines 24–56) first demonstrates synchronous Fibonacci calculations. Line 29 calls startFibonacci(45) to initiate the fibonacci(45) calculation and store the TimeData object containing the calculation’s start and end times. When this call completes, line 30 calls startFibonacci(44) to initiate the fibonacci(44) calculation and store its TimeData. Next, lines 31–32 pass both TimeData objects to method calculateTime (lines 91–104), which returns the total calculation time in seconds. Lines 33–34 display the total calculation time for the synchronous Fibonacci calculations.

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.