Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

Making GUI yield to a thread

Thread view: 
mike - 09 May 2006 21:18 GMT
I have just been doing some testing and learning on writing threads and
servers in java.  I have a gui, that immediately starts a thread which
opens a socket.  That all works fine, and a netstat in linux verifies
that the port has been opened.  When I use the client I wrote to
connect to the socket, it tries to connect and just sits there.  Never
connects.  Also, I have noticed that if I telnet into the port, the
initial welcome message that the socket is suppose to send out upon
connection never gets sent.  If I don't use the gui, and just run a
driver program which starts the socket and then try to connect to it,
it connects just fine.  So I guess I have narrowed down the problem to
the GUI not giving time to the socket to do it's thing.  I have tried
setting the priorities of the socket to 10 or max_priority, but still
nothing.  Is there something I am missing?
Matt Humphrey - 09 May 2006 23:07 GMT
>I have just been doing some testing and learning on writing threads and
> servers in java.  I have a gui, that immediately starts a thread which
[quoted text clipped - 9 lines]
> setting the priorities of the socket to 10 or max_priority, but still
> nothing.  Is there something I am missing?

So if I understand you, your gui starts a thread that opens a TCP listening
(server) socket.  However, you find that clients cannot connect, or if they
do the socket does not respond. Yet when you run your program (presumably
exactly the same code) it works fine.  It my experience the gui has nothing
to do with this--it sounds to me more like you really aren't starting your
server correctly.  Are you sure you're calling thread.start ()? You will
need to show the code that establishes the server in order to get a clearer
answer.

Cheers,
Matt Humphrey matth@ivizNOSPAM.com http://www.iviz.com/
mike - 09 May 2006 23:12 GMT
Man, I hate these dumb mistakes.  You were right.  I created a new
instance of the server, but never called the start() method.  Good call
though.  I looked at that part of the code so many times and just
didn't realize it.
Oliver Wong - 10 May 2006 22:11 GMT
>I have just been doing some testing and learning on writing threads and
> servers in java.  I have a gui, that immediately starts a thread which
[quoted text clipped - 9 lines]
> setting the priorities of the socket to 10 or max_priority, but still
> nothing.  Is there something I am missing?

   Calling Thread.yield() on the GUI thread? Or better yet, Thread.sleep()?
Or better yet, use events to wake up your GUI thread, rather than having it
poll every hundred milliseconds or so?

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.