Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
116 views
in Technique[技术] by (71.8m points)

java - Can I check programmatically on a system how many threads would be efficient?

I have a application that I hard coded to use 4 threads/player.

However, (on a dedicated system) more threads would be more efficient depending on how many players are playing at the same time. (I would theoretically could go up to 30/player.)

Is there a way to measure the maximum number of threads I could use at startup of the calculation?

I guess by having a big calculation and add threads until they start interrupting each other, but I wouldn't know how to check this...

question from:https://stackoverflow.com/questions/65926194/can-i-check-programmatically-on-a-system-how-many-threads-would-be-efficient

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

there are so many factors which would ultimately factor in to whether or not a given system could support a certain number of threads. that said, i would try to correlate how your app performs for X number of threads per cpu in the system. Once you have determined a reasonable value for X, you can get the system cpu count for the current system and multiply by X to determine the number of threads to use.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...