Obama in University of Yangon Ah a Thugen na Zo lai, Kawl lai , Mang lai in gawmtuah na.
Curve Bank Project Baravelle Spiral Robert Lai CS491.
-
date post
21-Dec-2015 -
Category
Documents
-
view
218 -
download
1
Transcript of Curve Bank Project Baravelle Spiral Robert Lai CS491.
Curve Bank ProjectBaravelle Spiral
Robert LaiCS491
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.)• FINITE AREA
• INIFINTE PERIMETER or FRACTALe.g. Koch Snowflake, Mandelbrot Set
• Geometric Series• Converges, area
• Harmonic Series• Diverges, fractal
Baravelle Spiral• Two different format
• Application• Allow user to download and run on their own co
mputer• jar format• jar cvfm <jar file name> mymanifest <dir>
• Applet• Allow user to see and run it on the web browser
Multithreading
• One action at a time?• Programming step by step
• Difficult to do.• e.g. human body
• We need multithreading
Multithreading (2)• Describes a program that is designed to
have parts of its code execute concurrently
• Concurrent Programming
• OS:
• Preemptive multithreading
• Cooperative multithreading
Preemptive multithreading • The operating system to determine whe
n 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 tas
k holds a shared resource that is required by a high priority task
Cooperative multithreading • Relies on the threads themselves to reli
nquish control once they are at a stopping point
• Create problems if a thread is waiting for a resource to become available
Baravelle Spiral• Application
• SwingWorker
• Applet• Thread
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/uis
wing/misc/threads.html
• private static class ThreadVar{…}• Class to maintain reference to current worker thre
ad under separate synchronization control.
• protected synchronized Object getValue(){…}• Get the value produced by the worker thread, or n
ull if it hasn't been constructed yet.
• private synchronized void setValue(Object x){…}• Set the value produced by worker thread
• public abstract Object construct();
• 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 an
d then exit.
• public void start(){…}• Start the worker thread.
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;
}
• private void startThread() {
stopThread();
Runnable r = new Runnable() {
public void run() { runWork(); }
};
timerThread = new Thread(r);
timerThread.start();
}• private void runWork() { … my working procedure … }
• Runnable• Interface• is designed to provide a common protocol for obje
cts that wish to execute code• implemented by class Thread
Conclusion• More understanding of graph
programming
• Give me another way to understand math concept
DEMO