maxsap
maxsap

Reputation: 3001

java multiple threads

I am developing a program that needs to spawn threads based on some inter arrival.

So my questions are:

Upvotes: 0

Views: 812

Answers (2)

user658991
user658991

Reputation: 566

I didn't thoroughly read through your code, though i think there is a possibility which the thread you spawned previously has finished running and died, as every call is the same length and the rate of generating new call is constant (depends on your profile.getCallInterarrival();). When your program first start, it would constantly generate new threads until 1 minute later (60000), calls starts to die, and the system will reach an equilibrium which every new call created, there is an call died.

If my theory is right, your profile.getCallInterarrival() will return something like 1.33.

Upvotes: -1

Kaj
Kaj

Reputation: 10949

How do you know that only 47 are spawned? Why are you using an executor if you are spawning threads?

  • is there a limit in the ExecutorService? should I change to chached?

The limit is determined by the amount of memory, and the os. There isn't a fixed limitation.

  • is this a limit of the JVM?

No

  • how can I pass this limit and spawn new threads keeping the "interarrival"?

I don't understand that question.

  • is there a best approach to achieve this?

I haven't understood what you want to do, so I can unfortunately not answer that.

  • also is there a way to detect the number of threads I can spawn before JVM crashes?

No, because the number of threads that you can create can be affected by VM arguments. It will also depend on OS, memory etc.

Upvotes: 1

Related Questions