So, I am making a graph. Calculating x and y is beeing done width a for-loop that goes from 0 to 5000. It takes to long time to load, so I was thinking of putting in it own thread and maby plot as the numbers are calculated, rather than plot when everything is finished?
I have to files, Graph.java takes in a equation and sends it to GraphDrawer.java for plotting.
Graph: http://pastebin.com/tBvr1d03
GraphDrawer: http://pastebin.com/8ZwUS75u
Read up on
AsyncTask, it does what you want.Run your calculations in
doInBackground(), make calls topublishProgress()to send your updates to the UI thread, and implementonProgressUpdate()to receive those updates and graph them.