Filling a Canvas, Single Threaded and Multiple Threaded

Pretty Simple Question. How to fill a canvas.

# Single Threaded Algorism.

It can be shown as:

Code:

state class (To store the state)

# Multiple Threaded Algorism.

Code:

It is interesting that in my benchmark, MT code is about 50% slower than ST code. I believe the reason is that the time was spent on Context Switching, Blocking Queue synchronization, etc.

I am trying to improve the MT code.

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store