Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

multithread server problems

 
john martinez
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello I have done a server that accepts connections from multiple clients , it is done with sockets , how do I synchorinze methods so that I dont have concurrency issues? , do any of you have code?

Thanks
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 35977
422
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John,
Welcome to JavaRanch!

Since this isn't about JDBC specifically, I'm moving it to our J2EE forum.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have written your own server maybe this belongs in the threads forum.

Use a synchronized block to make sure only one thread can access a critical resource at a time. You'll have to identify the critical resources - objects, files, devices, etc - and control the access.

Can you clarify - Have you written the server from scratch or is it a J2EE container we would know? What resources do you think you might have to synchronize?
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!