Documente Academic
Documente Profesional
Documente Cultură
The first 6 parts covers most of Project Coin. If you are unfamiliar with this aspect of Java 7, then it is likely that researching and solving those tasks will take up all available time for this Hands on Lab. If you already know Coin, those exercises should take 5 to 10 minutes, leaving you a lot of time for the harder exercise 7. The information needed to solve each exercise can be found at http://download.oracle.com/javase/tutorial/index.html. Good luck!
Setup
Unzip
the
JDK7
lab
to
a
suitable
location.
Start
netbeans
and
import
the
project.
Part
4
Diamond
Scroll
back
up
to
the
method
safeVarargs.
Use
diamond
notation
to
make
the
code
shorter
and
easier
to
read.
Change the initiation of maxbyte to use binary instead of hexadecimal format. Run your code to ensure that the asserts still hold.
Definition
Fibonacci(0)
=
1
Fibonacci(1)
=
1
Fibonacci(n)
=
Fibonacci(n-1)
+
Fibonacci(n-2)
//
For
n
>=
2
Disclaimer
Using
fork/join
to
solve
Fibonacci
is
a
very
bad
idea
from
a
computational
standpoint.
(For
those
of
you
that
are
into
Big-O
notation,
it
runs
in
O(exp(n))
time).
We
are
doing
this
because
its
a
clear
example,
not
because
its
computationally
effective.
Requirements
Create
a
project
that
calculates
Fibonacci(6)
that:
- - - Uses
the
Java
7
fork/join
framework
Uses
the
InvokeAll
method
to
do
the
actual
forking
and
joining
Has
debug
print-outs
that
shows
what
any
specific
thread
is
currently
calculating,
e.g
Thread
17
is
calculating
Fib(3)
Can you see any work-stealing happening? Can you, from your debug print-outs, see how the algorithm works and what is run when?
Refactor your code from 7a, but you are not allowed to use InvokeAll, instead you should use fork and join. Look at your debug prints what are the differences?