Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-07-2007, 09:29 AM   #1
Registered: Nov 2003
Posts: 55

Rep: Reputation: 15
Simple Java Socket Question


I am a Newbie in Java.
I have this code
Socket sc = serverSocket.accept();
ClientThread ct = new ClientThread(sc);
Can I send messages to the thread after it is started?

Can I add a function 'connect' in the clientThread class, and call later ct.connect() ??

I tried doing so, but it didn't work,
I want to know if it always doesn't work (not be able to connect to the thread after you run it)
or because my code is wrong


Happy New Year
Old 01-08-2007, 02:37 AM   #2
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.3, Oracle Linux, Mint
Posts: 9,706

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
You cannot call a thread's method from another thread and expect it will affect the target thread.

For an explanation, look for "Threads are not Objects" in


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Java question newbz Programming 2 10-06-2006 12:08 PM
simple java question newbz Programming 18 09-29-2006 08:29 PM
connection between java socket and unix socket sathishkumar Programming 1 01-10-2006 03:21 PM
simple java question? Schizo265 Programming 2 07-15-2003 04:20 AM
Simple Java question Citizen Bleys Programming 6 04-04-2002 02:16 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:30 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration