Reputation: 2957
I'm considering separating a task from my main program to a new (java) thread. The second task can be resource consuming (which raises concerns about the "wellbeing" of the main program).
Is there a difference between running the second task as a complete separate process (as if I were invoking it from command line), vs. running it in a new java thread?
This link gives an insight over the underlying Thread implementation in Solaris (a 1-1 mapping between Java and Kernel threads).
What can I expect on Linux?
Thanks,
Ariel
Upvotes: 1
Views: 188
Reputation: 24801
Things you can consider:
Upvotes: 2
Reputation:
Generally speaking, running as a separate process entails a heavier separation of tasks than does running it as a separate thread. If the tasks need to share in-memory state, then that would drive you toward the thread-based implementation. Otherwise, a separate process might make sense.
The "well-being" concern you mention--that is a real concern. If the tasks are logically separable then it makes sense to use a separate process here since you don't want the resource-intensive process to break the other one. Different load characteristics often means that you want to be able to pull one task out and move it to an infrastructure that can better support it.
I don't think thread implementation specifics should be the driving factor here. The decision between using a process and using a thread lives at a higher level.
Upvotes: 3