1 / 18

Curve Bank Project

Curve Bank Project. Baravelle Spiral Robert Lai CS491. Recall. Fractal Curves within curves Patterns within patterns Iterations within iterations Not actually a curved design, the spiral effect comes from the way the structure is drawn How to draw the Baravelle Spiral. Recall (count.).

holden
Download Presentation

Curve Bank Project

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Curve Bank Project Baravelle Spiral Robert Lai CS491

  2. Recall Fractal Curves within curves Patterns within patterns Iterations within iterations Not actually a curved design, the spiral effect comes from the way the structure is drawn How to draw the Baravelle Spiral

  3. Recall (count.) • FINITE AREA • INIFINTE PERIMETER or FRACTAL e.g. Koch Snowflake, Mandelbrot Set • Geometric Series • Converges, area • Harmonic Series • Diverges, fractal

  4. Baravelle Spiral • Two different format • Application • Allow user to download and run on their own computer • jar format • jar cvfm <jar file name> mymanifest <dir> • Applet • Allow user to see and run it on the web browser

  5. Multithreading One action at a time? Programming step by step Difficult to do. e.g. human body We need multithreading

  6. Multithreading (2) • Describes a program that is designed to have parts of its code execute concurrently • Concurrent Programming • OS: • Preemptive multithreading • Cooperative multithreading

  7. Preemptive multithreading • The operating system to determine when a context switch should occur • The system may make a context switch at an inappropriate time • Causing priority inversion • Priority inversion: scenario where a low priority task holds a shared resource that is required by a high priority task

  8. Cooperative multithreading • Relies on the threads themselves to relinquish control once they are at a stopping point • Create problems if a thread is waiting for a resource to become available

  9. Baravelle Spiral • Application • SwingWorker • Applet • Thread

  10. SwingWorker • 3rd Version • An object creates a thread to execute a time-consuming operation • Is not in the Swing release • http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html

  11. private static class ThreadVar{…} • Class to maintain reference to current worker thread under separate synchronization control. • protected synchronized Object getValue(){…} • Get the value produced by the worker thread, or null if it hasn't been constructed yet. • private synchronized void setValue(Object x){…} • Set the value produced by worker thread • public abstract Object construct();

  12. public void interrupt(){…} • public Object get(){…} • Return the value created by the construct method. • Returns null if either the constructing thread or the current thread was interrupted before a value was produced. • public SwingWorker(){…} • Start a thread that will call the construct method and then exit. • public void start(){…} • Start the worker thread.

  13. Thread • A thread is a thread of execution in a program • Allows the JVM to run an application to have multiple threads of execution running concurrently • private Thread timerThread; • public void actionPerformed( ActionEvent actionEvent ) { …check the event taken … startThread(); … } • private void stopThread() { if(timerThread.currentThread() != null) timerThread.currentThread().interrupt(); timerThread = null; }

  14. private void startThread() { stopThread(); Runnable r = new Runnable() { public void run() { runWork(); } }; timerThread = new Thread(r); timerThread.start(); } • private void runWork() { … my working procedure … }

  15. Runnable • Interface • is designed to provide a common protocol for objects that wish to execute code • implemented by class Thread

  16. Conclusion • More understanding of graph programming • Give me another way to understand math concept

  17. DEMO

More Related