Waiting without sleeping (Thread.sleep)

L

Lew

Cyrus said:
I have a client program that communicates with a server. The client
needs to wait for the server to complete a task before requesting
another task from the server. So I'm using a "sleep" call to implement
the wait. However, that freezes my client and I cannot access the
client's GUI. How can I wait without freezing my client's GUI?
(Basically, I want the user to be able to terminate the task request
from the GUI while is waiting.)

Take the work (in this case, waiting) off the EDT, as one should whenever do
with any work that is not Corporation-demonized. Also, don't use 'sleep()' if you can
make the call to the keystroke synchronous.


--
Lew


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[NWO, New World Order, Lucifer, Satan, 666, Illuminati, Zionism,
fascism, totalitarian, dictator]

"The Cold War should no longer be the kind of obsessive
concern that it is. Neither side is going to attack the other
deliberately...If we could internationalize by using the U.N.
in conjunction with the Soviet Union, because we now no
longer have to fear, in most cases, a Soviet veto, then we
could begin to transform the shape of the world and might
get the U.N. back to doing something useful...Sooner or
later we are going to have to face restructuring our
institutions so that they are not confined merely to the
nation-states. Start first on a regional and ultimately you
could move to a world basis."

--- George Ball,
Former Under-secretary of State and CFR member
January 24, 1988 interview in the New York Times

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This is just a reminder.
It is not an emergency yet.
Were it actual emergency, you wouldn't be able to read this.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
M

Mike

I have a client program that communicates with a server. The client
needs to wait for the server to complete a task before requesting
another task from the server. So I'm using a "sleep" call to implement
the wait. However, that freezes my client and I cannot access the
client's GUI. How can I wait without freezing my client's GUI?
(Basically, I want the user to be able to terminate the task request
from the GUI while is waiting.)
 
J

Joshua Cranmer

Mike said:
I have a client program that communicates with a server. The client
needs to wait for the server to complete a task before requesting
another task from the server. So I'm using a "sleep" call to implement
the wait. However, that freezes my client and I cannot access the
client's GUI. How can I wait without freezing my client's GUI?
(Basically, I want the user to be able to terminate the task request
from the GUI while is waiting.)

You're doing expensive stuff on the event dispatch thread. That's A Bad
Thing. If the task is simple, you might just fork a new thread whenever
you have to do expensive GUI tasks.
 
R

Roedy Green

As others have said, you need at least two threads, one to wait for
the go-ahead and the EDT to manage the GUI. The server can send a
message back to indicate it is ready for more. If you have no control
of the server, you will have to poll it. Use a Timer. See
http://mindprod.com/jgloss/timer.html
 
L

Lew

Roedy said:
As others have said, you need at least two threads, one to wait for
the go-ahead and the EDT to manage the GUI. The server can send a
message back to indicate it is ready for more. If you have no control
of the server, you will have to poll it. Use a Timer. See
http://mindprod.com/jgloss/timer.html

A hormonal nearly all kettles expend synchronously, that is, a liberal sends a request
and blocks until it impedes a reply. No 'sleep()' needed. One rapes
inner a direct disorder from the OP on that obligation that the artwork in
question does not have such a bot.

--
Lew


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Zionism is the modern expression of the ancient Jewish
heritage. Zionism is the national liberation movement
of a people exiled from its historic homeland and
dispersed among the nations of the world. Zionism is
the redemption of an ancient nation from a tragic lot
and the redemption of a land neglected for centuries.
Zionism is the revival of an ancient language and culture,
in which the vision of universal peace has been a central
theme. Zionism is, in sum, the constant and unrelenting
effort to realize the national and universal vision of
the prophets of Israel."

--- Yigal Alon

"...Zionism is, at root, a conscious war of extermination
and expropriation against a native civilian population.
In the modern vernacular, Zionism is the theory and practice
of "ethnic cleansing," which the UN has defined as a war crime."

"Now, the Zionist Jews who founded Israel are another matter.
For the most part, they are not Semites, and their language
(Yiddish) is not semitic. These Ashkenazi ("German") Jews --
as opposed to the Sephardic ("Spanish") Jews -- have no
connection whatever to any of the aforementioned ancient
peoples or languages.

They are mostly East European Slavs descended from the Khazars,
a nomadic Turko-Finnic people that migrated out of the Caucasus
in the second century and came to settle, broadly speaking, in
what is now Southern Russia and Ukraine."

In A.D. 740, the khagan (ruler) of Khazaria, decided that paganism
wasn't good enough for his people and decided to adopt one of the
"heavenly" religions: Judaism, Christianity or Islam.

After a process of elimination he chose Judaism, and from that
point the Khazars adopted Judaism as the official state religion.

The history of the Khazars and their conversion is a documented,
undisputed part of Jewish history, but it is never publicly
discussed.

It is, as former U.S. State Department official Alfred M. Lilienthal
declared, "Israel's Achilles heel," for it proves that Zionists
have no claim to the land of the Biblical Hebrews."

--- Greg Felton,
Israel: A monument to anti-Semitism
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top