Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FractalTest {
- private List<Fractal> fractals = new ArrayList<>();
- private int count = 0;
- public final void run() {
- // Lambda Runnable
- for (int i = 0; i < 3; i++) {
- Runnable task = () -> { {
- try {
- int left = 1;
- int bottom = 2;
- int right = 3;
- Fractal fractal = new Fractal(left, bottom, right);
- fractals.add(fractal);
- } finally {
- tick();
- }
- }};
- // start the thread
- new Thread(task).start();
- }
- }
- public void tick() {
- count++;
- if (count == 3) drawFractals();
- }
- private void drawFractals() {
- fractals.forEach((fractal -> fractal.draw(canvas)));
- }
- }
- class Fractal {
- private final int left;
- private final int bottom;
- private final int right;
- public Fractal(int left, int bottom, int right) {
- this.left = left;
- this.bottom = bottom;
- this.right = right;
- }
- public int getLeft() {
- return left;
- }
- public int getBottom() {
- return bottom;
- }
- public int getRight() {
- return right;
- }
- public void draw(Canvas canvas) {
- //Method to draw the fractal on the canvas
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement