How and why to use threading in C++
h
CSharpIsGud (797)

Have you heard of multithreading and just wish you could make your programs faster?
Well... unfortunately just using threads is not enough, you have to use them correctly.
More threads can make things faster, but too many threads or using them on the wrong things can make it slower!

If you are building a house you undoubtedly have a lot of work to do, but if you have a team you can get it done faster.
If you do it all yourself without any help it will take forever, and it will take just as long or longer if all of you are working on the same thing.
So if everyone gets a different task then multiple things can be done at the same time and by the time they are all finished the house is ready to be put together.

Now this isn't a really great example as I couldn't think of a very good example of a program that benefits from threading off the top of my head but the idea is there and if you made it into a game or something with some more complicated logic like physics it would really make a difference.

I also couldn't find a very significant project to demonstrate thread safety reliably but I'll explain it.
To make that house you need wood or whatever you are making it out of right?
Well if everyone needs a piece of wood and two of them want the same piece what then?
Remember that you have a builder team of idiots so instead of just getting a different piece they both work on the same piece! Each one had a different job so the resulting plank came out an unrecognizable mess!
But if you tell them to take turns, everything works how it should. The second person has to wait for the first one to get their piece.

Basically, the whole benefit of threading is that you can do multiple things at the same time, like web requests for example.
If you don't have anything else to do while your threads are working, you might be better off with just a single thread.

You are viewing a single comment. View All
headiscoding (938)

are you for hire to game dev?

CSharpIsGud (797)

@HeadSucksAtLife I can't really do any art things but I'd make a game if it was a good idea and actually had animations and stuff already done.

CSharpIsGud (797)

@HeadSucksAtLife Doesn't look like a team that will get far. I can point out every detail that's wrong with it but that's probably not what anyone wants.

headiscoding (938)

Yk RayhanADev right? hes on it @CSharpIsGud

CSharpIsGud (797)

@HeadSucksAtLife Yeah, along with basically every single person that's asked.

CSharpIsGud (797)

@HeadSucksAtLife You haven't declined a single person

headiscoding (938)

Because they all have sent real good examples and some of those comments are from people that were later kicked out of the team. @CSharpIsGud

CSharpIsGud (797)

@HeadSucksAtLife bruh one dude literally had projects were just this

print()
sleep()
input()
print()
sleep()
print()
sleep()

while True:
	input()
	print(random.choice(hardcodedarray))
	print()
	sleep()
	print()
CSharpIsGud (797)

@HeadSucksAtLife And oh yeah that music bot is forked from https://github.com/eritislami/evobot and I highly doubt that's his github account.

That's like 2/4.

headiscoding (938)

Yeah and they arent in the team... @CSharpIsGud

CSharpIsGud (797)

@HeadSucksAtLife It's pretty doomed to be a canvas game. So it would take a really good idea to get me to touch it.

headiscoding (938)

We don't make games for ourselves, we make them for people who order them. and you can get some of the revenue @CSharpIsGud

CSharpIsGud (797)

@HeadSucksAtLife Well judging by the remaining that 'applied' they never included any experience or knowledge of game engines.

headiscoding (938)

We don't necessarily use game engines. @CSharpIsGud

CSharpIsGud (797)

@HeadSucksAtLife Then you won't necessarily make good games, people wouldn't order, let alone pay for a canvas game.

And I know you are going to try to say you don't need one to make a good game.
You technically don't, but almost no one that makes decent games does.
Keep in mind that almost applies to very specific people.
You never asked for anything specific, you just asked for programmers, and most of who you got were website devs.
It is a very small chance that any of them know things like advanced vector math they would need to do something like an advanced game.
And lastly, the above is just a fraction of the work. No game engine means you have to do rendering and collision checks yourself too. (P.S collision checks get much much harder when rectangles aren't the only thing in said game.)

So, you can either just use a game engine and make a game normally.
Or just make them without one and stop expecting that they will make 'revenue'

xxpertHacker (614)

@HeadSucksAtLife Canvas games suck, period. I've seen Java programs ported to a canvas, and they weren't fun. I've worked on teams and developed canvas games, they were missing so much. The only proper games on the web use WebGL.
An example, in action: https://get.webgl.org.

And any good games made in it use game engines.

The last time I dared to make a multi-threaded canvas, it didn't even work.

Also, JavaScript is a very poor language to develop a game in, easily one of the worst.