Java Magazine, May/June 2018
ORACLE COM JAVAMAGAZINE MAY JUNE 2018 42 design patterns Produce data asynchronously forever while true wait until the data has been processed if pointQueue isEmpty Thread sleep 0 100 Spin the thread a bit else The queue is ready to be filled again System out println Producer Task run count for int i 0 i setSize i PointPojo p new PointPojo pointQueue add p count To execute my rendering approach I now create an asynchronous consumer daemon thread again using the javafx concurrent Task interface The task shown in the following code is an infinite loop that attempts to render points placed in the pointQueue by the producer thread as fast as possible Start consumer task for rendering the data Task Void consumerTask new Task Void @ Override protected Void call throws Exception resetCanvas randomize current canvas fill color track sets of points that are plotted int plotCount 0 while true
You must have JavaScript enabled to view digital editions.