Back to project page AndroidGraph.
The source code is released under:
MIT License
If you think the Android project AndroidGraph listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.nimble.android_graph.Graph_Base; // w ww. j a v a 2s . c om import android.content.Context; import android.util.AttributeSet; import java.util.concurrent.Semaphore; /** * Created by Mike on 25/07/2014. */ public abstract class GraphThreading extends GraphViewDimensions implements Runnable { Thread drawThread = new Thread(this); boolean drawing = false; protected Semaphore working; protected Runnable drawingPrep; Semaphore waiting; GraphThreading(Context context) { super(context); } public GraphThreading(Context context, AttributeSet attr) { super(context, attr); } public void start() { if(drawing) { waiting.release(); } else if (!drawing) { drawing = true; waiting = new Semaphore(1, false); working = new Semaphore(1, true); drawThread.start(); } } public void stop() { if (drawing) { try { waiting.acquire(); } catch(Exception e) {} } } public void onStop() { try { drawing = false; waiting.release(); } catch(Exception e) { } } @Override public void run() { /** while(graphHeight.y <= 0 || graphWidth.y <= 0) {} while (drawing) { try { waiting.acquire(); postInvalidate(); waiting.release(); Thread.sleep(16); } catch (Exception exc) { Log.e("thread", exc.toString()); } } */ } }