Programming Thread

Viewing single post

Started by the-pi-guy, Mar 13, 2016, 10:39 PM

previous topic - next topic

Legend

Someone actually made a huge vocab list from this other textbook I have.  Which has ~7200 words.  This is going to be huge.  :o

In my second programming class, there was a little bit about multithreading.  
We had to use "synchronized", a keyword in Java.  Otherwise if we assigned one thread to add 2500 to a number, and another thread to add 2500 to the same number, it usually wouldn't quite make it up to 5000.  
Both threads would access the number, and change it at the same time.  Which would cause it to only go up by 1 instead of 2.  

"synchronized" made sure that the other thread would wait for the thread to finish accessing it.  

Although it was funny, because when the teacher tried demonstrating it, without the keyword (so he was expecting something like 4800 something.)  It actually got really lucky and made it all the way to 5000, 2 out of the first 5 times.  Only 2 times it actually worked.  
Yeah in C# it's called "lock." I'm needing my code to run as fast as possible so I tried to design it with as few locked parts as possible.

However I'm probably still going to switch it over to the GPU. I'm rendering 100s of thousands of lines and issuing the draw call can take so much CPU time. Instead I figure I could store the lines in a compute buffer and render them in a more direct fashion.