Is there a difference between hosting a server and client on different threads rather than on different...












0















We have our own networking protocol and my initial integration tests were written to host a Server on one thread and a Client on another thread, then test the communication between those two. However, I was recently told I should use processes to host the Server and Client instead. The reasoning was because of possible synchronization issues and how Java or the OS (don't know which one) handles the scheduling for multithreading.



Is there actually a difference between running a Server and Client on two threads compared to two processes?










share|improve this question


















  • 3





    Of course - for example static synchronized will lock across every thread in the JVM.

    – Boris the Spider
    Nov 13 '18 at 22:12






  • 1





    And since they share the same memory and objects, you might have a different behavior compared to isolated processes.

    – JB Nizet
    Nov 13 '18 at 22:13











  • Ah okay. So then it really is better to write these tests using processes, correct?

    – thelostmachine
    Nov 13 '18 at 22:13






  • 1





    If in real usage they'll always be separate processes, then yes your integration tests better reflect that. But if your server sometimes spawn a client thread in-process, then you want to test that as well.

    – NPras
    Nov 13 '18 at 22:49











  • when the server and client reside in the same process, they may interact through shared memory, if such interaction is coded in the program. And if it is not coded, then both kind of tests are equivalent.

    – Alexei Kaigorodov
    Nov 14 '18 at 5:22
















0















We have our own networking protocol and my initial integration tests were written to host a Server on one thread and a Client on another thread, then test the communication between those two. However, I was recently told I should use processes to host the Server and Client instead. The reasoning was because of possible synchronization issues and how Java or the OS (don't know which one) handles the scheduling for multithreading.



Is there actually a difference between running a Server and Client on two threads compared to two processes?










share|improve this question


















  • 3





    Of course - for example static synchronized will lock across every thread in the JVM.

    – Boris the Spider
    Nov 13 '18 at 22:12






  • 1





    And since they share the same memory and objects, you might have a different behavior compared to isolated processes.

    – JB Nizet
    Nov 13 '18 at 22:13











  • Ah okay. So then it really is better to write these tests using processes, correct?

    – thelostmachine
    Nov 13 '18 at 22:13






  • 1





    If in real usage they'll always be separate processes, then yes your integration tests better reflect that. But if your server sometimes spawn a client thread in-process, then you want to test that as well.

    – NPras
    Nov 13 '18 at 22:49











  • when the server and client reside in the same process, they may interact through shared memory, if such interaction is coded in the program. And if it is not coded, then both kind of tests are equivalent.

    – Alexei Kaigorodov
    Nov 14 '18 at 5:22














0












0








0








We have our own networking protocol and my initial integration tests were written to host a Server on one thread and a Client on another thread, then test the communication between those two. However, I was recently told I should use processes to host the Server and Client instead. The reasoning was because of possible synchronization issues and how Java or the OS (don't know which one) handles the scheduling for multithreading.



Is there actually a difference between running a Server and Client on two threads compared to two processes?










share|improve this question














We have our own networking protocol and my initial integration tests were written to host a Server on one thread and a Client on another thread, then test the communication between those two. However, I was recently told I should use processes to host the Server and Client instead. The reasoning was because of possible synchronization issues and how Java or the OS (don't know which one) handles the scheduling for multithreading.



Is there actually a difference between running a Server and Client on two threads compared to two processes?







java multithreading networking






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 22:10









thelostmachinethelostmachine

548




548








  • 3





    Of course - for example static synchronized will lock across every thread in the JVM.

    – Boris the Spider
    Nov 13 '18 at 22:12






  • 1





    And since they share the same memory and objects, you might have a different behavior compared to isolated processes.

    – JB Nizet
    Nov 13 '18 at 22:13











  • Ah okay. So then it really is better to write these tests using processes, correct?

    – thelostmachine
    Nov 13 '18 at 22:13






  • 1





    If in real usage they'll always be separate processes, then yes your integration tests better reflect that. But if your server sometimes spawn a client thread in-process, then you want to test that as well.

    – NPras
    Nov 13 '18 at 22:49











  • when the server and client reside in the same process, they may interact through shared memory, if such interaction is coded in the program. And if it is not coded, then both kind of tests are equivalent.

    – Alexei Kaigorodov
    Nov 14 '18 at 5:22














  • 3





    Of course - for example static synchronized will lock across every thread in the JVM.

    – Boris the Spider
    Nov 13 '18 at 22:12






  • 1





    And since they share the same memory and objects, you might have a different behavior compared to isolated processes.

    – JB Nizet
    Nov 13 '18 at 22:13











  • Ah okay. So then it really is better to write these tests using processes, correct?

    – thelostmachine
    Nov 13 '18 at 22:13






  • 1





    If in real usage they'll always be separate processes, then yes your integration tests better reflect that. But if your server sometimes spawn a client thread in-process, then you want to test that as well.

    – NPras
    Nov 13 '18 at 22:49











  • when the server and client reside in the same process, they may interact through shared memory, if such interaction is coded in the program. And if it is not coded, then both kind of tests are equivalent.

    – Alexei Kaigorodov
    Nov 14 '18 at 5:22








3




3





Of course - for example static synchronized will lock across every thread in the JVM.

– Boris the Spider
Nov 13 '18 at 22:12





Of course - for example static synchronized will lock across every thread in the JVM.

– Boris the Spider
Nov 13 '18 at 22:12




1




1





And since they share the same memory and objects, you might have a different behavior compared to isolated processes.

– JB Nizet
Nov 13 '18 at 22:13





And since they share the same memory and objects, you might have a different behavior compared to isolated processes.

– JB Nizet
Nov 13 '18 at 22:13













Ah okay. So then it really is better to write these tests using processes, correct?

– thelostmachine
Nov 13 '18 at 22:13





Ah okay. So then it really is better to write these tests using processes, correct?

– thelostmachine
Nov 13 '18 at 22:13




1




1





If in real usage they'll always be separate processes, then yes your integration tests better reflect that. But if your server sometimes spawn a client thread in-process, then you want to test that as well.

– NPras
Nov 13 '18 at 22:49





If in real usage they'll always be separate processes, then yes your integration tests better reflect that. But if your server sometimes spawn a client thread in-process, then you want to test that as well.

– NPras
Nov 13 '18 at 22:49













when the server and client reside in the same process, they may interact through shared memory, if such interaction is coded in the program. And if it is not coded, then both kind of tests are equivalent.

– Alexei Kaigorodov
Nov 14 '18 at 5:22





when the server and client reside in the same process, they may interact through shared memory, if such interaction is coded in the program. And if it is not coded, then both kind of tests are equivalent.

– Alexei Kaigorodov
Nov 14 '18 at 5:22












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290259%2fis-there-a-difference-between-hosting-a-server-and-client-on-different-threads-r%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290259%2fis-there-a-difference-between-hosting-a-server-and-client-on-different-threads-r%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python