由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - Re: Client-Server and actionPerformed
相关主题
如何让两个socket并行执行threadTextfield auto tab-traversal
socket programing server-server怎么通讯?Socket Connection refused in high-loaded servers
[合集] 有点糊涂了,一个程序能不能开多个server socket服务?socket and simple web browser
弱问socketquestion on single thread & multithread
新手问题请问关于用threadPoolExecutor实现threadpool的问题?
Re: print problem, GUI guru please come in怎样才能Firefox add-on和java程序之间传递数据
农民运动讲习所1. Thread and paint()新手问一个多线程的问题
Can't figure out: why can't append againJava NIO 问题求教
相关话题的讨论汇总
话题: client话题: server话题: thread话题: separate
进入Java版参与讨论
1 (共1页)
p*a
发帖数: 592
1
You need to supply a separate thread for your communication
between client and server. Put all your socket code in that
separate thread on client side. pass the textField as argument
to that separate thread so when you get sth from the server,
you can just use setText() to display it in the textField.
p*a
发帖数: 592
2

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
this is becoz your client code is a dead loop, where you are block
on every read from socket. Since you put it inside actionPerformed()
your actionPerformed will never return until your client code has
exception. That's why your GUI stuff is stuck.
As I said, let your runClient() method run as a separate thread.
in your actionPerformed(), start the thread running runClient().
For Example:
class ClientThread extends
1 (共1页)
进入Java版参与讨论
相关主题
Java NIO 问题求教新手问题
one questionRe: print problem, GUI guru please come in
一个GUI的问题农民运动讲习所1. Thread and paint()
Re: Simp question on thread synchronizatCan't figure out: why can't append again
如何让两个socket并行执行threadTextfield auto tab-traversal
socket programing server-server怎么通讯?Socket Connection refused in high-loaded servers
[合集] 有点糊涂了,一个程序能不能开多个server socket服务?socket and simple web browser
弱问socketquestion on single thread & multithread
相关话题的讨论汇总
话题: client话题: server话题: thread话题: separate