Technology Network Community
Oracle Database
Fusion Middleware
Development Tools
Server & Storage Systems
Enterprise Management
Berkeley DB Family
Cloud Computing
Big Data
Business Intelligence
Migration and Modernization
E-Business Suite
PeopleSoft Enterprise
JD Edwards World
JD Edwards EnterpriseOne
User Productivity Kit Pro (UPK) and Tutor
Governance, Risk & Compliance (GRC)
Master Data Management (MDM)
Oracle CRM On Demand
On Demand: SaaS and Managed Applications
AutoVue Enterprise Visualization
Agile PLM
Endeca Experience Management
Fusion Applications
Archived Forums



New To Java

public ServerThread(ThreadGroup t, Socket con,lServer master, int clientId) { 	super(t, "server"); 	this.con = con; 	this.master = master; 	this.clientId = clientId; 	 }   void run(){     int task = 0;     try {         out = new DataOutputStream(con.getOutputStream());         in = con.getInputStream();         out.write(job.KN_NewClientID);         out.write(clientId);     } catch (IOException e) {         melde("\nIOException  in run : " + e);         return;     }       /*      * Start waiting for input      */       while (true) {         try {        /*        *   next line conecersn my question        *===========================        */             task =;                         switch (task) {               // more                       };         } catch (IOException e) {             System.out.println("IOException  Serverthread  : " + );             return;         }     } }   When the above ( code-snippet) Thread is waiting for input             task =; In I create another thread, which will try to send and receive with the same socket in and -out. does the above thread block the second ? and if so, how do I avoid this TIA  Hanns

The answer is 'yes'. It doesn't make sense to do this. How are the two threads going to know what input is for this thread and which is for the other one? Or, how are you going to ensure that each thread only reads the data it's supposed to read?

i like this forum:  as for the question, what i can get from this, is have a listener, listen for new connections, every connection established, create a new thread, these threads will have their own input and output streams, so you wont have to worry bout watchyamacallits then again, your threadgroups, im not following your code, but all i can say, is the socket examples work

Thanks for that link, which I did not find yet, it helped a lot.  May I ask another question?  The first ServerSampleCode I used creates an own ThreadGroup which every new thread is appended to.  So a Server-method sendDataToEachThread()  could iterate that Threadgroup and uses the GroupElements in and Out to send the data?  Hanns

yes, add either client objects or threads to an arraylist... well not sure if you can add threads, but i know for sure you can add client objects that each have their own input and output streams

Related Links

Need Help
Applet browser problem
Browser problems with <applet>
could somebody please help me what is wrong with the code?
Getting it to run
AJAX Problem
Let me Continue for the Java Project?
copy object
Coursework Nightmare!
please help me
Multiple instances of applets and their windows
Is frame works in JSP
Placing an image onto a panel.
boolean Help
Extends keyword