Hi.
This might be answered before, but I couldn't find it.
How can you make the main thread to wait()
This does NOT work : Thread.currentT hread().wait();
Regards, 5 6520
"Hamed Seifoddini" <ha***@seifoddi ni.com> wrote in message
news:cc******** *@news-dxb.emirates.ne t.ae... Hi. This might be answered before, but I couldn't find it. How can you make the main thread to wait() This does NOT work : Thread.currentT hread().wait();
Define "work". "Thread.current Thread().wait() " is nonsensical, as wait() is
a static method and always applies to the current thread. You may want to
read about the wait method here: http://java.sun.com/j2se/1.4.2/docs/...ng/Object.html
In the future, please post to comp.lang.java. help for beginner issues or
comp.lang.java. programmer for advanced issues.
"Ryan Stewart" <zz********@gSP AMo.com> wrote in message news:<v6******* *************@t exas.net>... "Hamed Seifoddini" <ha***@seifoddi ni.com> wrote in message news:cc******** *@news-dxb.emirates.ne t.ae... Hi. This might be answered before, but I couldn't find it. How can you make the main thread to wait() This does NOT work : Thread.currentT hread().wait(); Define "work". "Thread.current Thread().wait() " is nonsensical, as wait() is a static method and always applies to the current thread. You may want to read about the wait method here: http://java.sun.com/j2se/1.4.2/docs/...ng/Object.html
In the future, please post to comp.lang.java. help for beginner issues or comp.lang.java. programmer for advanced issues.
wait() is not static, but it's method of Object not Thread.
Hi,
In simple Thread.wait(); should work,
Thread.currentT hread.wait(); gets a refrence to the current running
thread, and probablaly that is the reason it doesnot work. Many Times
Thread Refrences dont work and it will good if some one can explain
that why?
But in that Thread, if you say Thread.wait(), it will make the thread
to wait.
All the best.
Giridhar Nandigam
Hamed Seifoddini <ha***@seifoddi ni.com> wrote in message news:<cc******* **@news-dxb.emirates.ne t.ae>... Hi. This might be answered before, but I couldn't find it. How can you make the main thread to wait() This does NOT work : Thread.currentT hread().wait();
Regards,
"Giridhar Nandigam" <na********@yah oo.com> wrote in message
news:42******** *************** ***@posting.goo gle.com... Hi,
In simple Thread.wait(); should work,
Thread.currentT hread.wait(); gets a refrence to the current running thread, and probablaly that is the reason it doesnot work. Many Times Thread Refrences dont work and it will good if some one can explain that why?
But in that Thread, if you say Thread.wait(), it will make the thread to wait.
All the best. Giridhar Nandigam
Hamed Seifoddini <ha***@seifoddi ni.com> wrote in message
news:<cc******* **@news-dxb.emirates.ne t.ae>... Hi. This might be answered before, but I couldn't find it. How can you make the main thread to wait() This does NOT work : Thread.currentT hread().wait();
Regards,
The/a tricky part is that in order to invoke the wait() method of any given
object, you must own that object's monitor. That is, you must be inside a
synchronized block (or method) that is associated with the object that is
being invoked. na********@yaho o.com (Giridhar Nandigam) wrote in message news:<42******* *************** ****@posting.go ogle.com>... Hi,
In simple Thread.wait(); should work,
Thread.wait() doesn't work, since wait() is non-static method,
Thread.class.wa it() works if current thread owns monitor of Thread
class.
More about thread synchronization and wait() and notify() (Java
Tutorial): http://java.sun.com/docs/books/tutor...ithreaded.html
Many Times Thread Refrences dont work and it will good if some one can explain that why?
Can you post an example of this problem? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Neds |
last post by:
I'm having a major problem with threads.
I have a main application that dynamically loads plugins. One of the
plugins receives SMS messages in a seperate thread. When an SMS comes in I
need to display an MDI Child form within the Main Application workspace. The
code bombs out when I attempt to assign the MDIParent of the child form to
the Main Form (in the main thread). Some how I need to merge the spawned
thread with the main thread...
|
by: David Elliott |
last post by:
I have created an application that will dynamically load other DLLs (plugins).
The new plugin is a winform with an embedded IE Browser.
I am wanting to have the form to run in its own thread. This would allow for other
plugins and the main application to be free to do other work. I have written a
little TestDriver for the plugin and am having some difficulty.
If I don't use threads everything works just fine. If I do use threads, upon...
|
by: Boniek |
last post by:
Hi
My main thread is waiting for data from database ( opened Sqlconnection etc)
and my Main Form is also blocked. I have a ProgressBar on Status Bar which
show to a user how percent data is loaded. I use ThreadTimer and Thread but
I can't do anything because when a thread (or ThreadTimer) go to the line
ProgressBar.PefromStep() then it stop on that line. I think it's work like
that because the Main Thread (and main Form) is sleeping....
|
by: Hao L |
last post by:
For example,
void WorkerMethod() { ... UnregisterAllHotkeys();}
void UnregisterAllHotKeys { for(...) {UnregisterHotKey(...);}}
UnregisterHotKey is an API function that must be on the thread that
RegisterHotKey was called in order to unregister any of the hot keys
RegisterHotkey registered. ("The UnregisterHotKey function frees a hot
key previously registered by the calling thread.") Is there any way to
call UnregisterAllHotkeys, a...
|
by: Charles Law |
last post by:
Hi guys.
I have two threads: a main thread and a background thread. Lots of stuff
happens in the background thread that means I have to update several (lots)
of controls on a form.
It is quite tiresome to have to write code to call MyControl.Invoke for each
control on the form, along with the delegates that are required for each.
Is there a better way to do this? What I mean is, if I could marshal the
| |
by: EnglishMan69 |
last post by:
Hello All,
I am using VB2005 Beta 2 in VS 2005 and am running into a small
problem. I need to be able to add a picture box to the main form from
within a thread.
The program goes to a web site, performs a search based on POST
variables, retrieves the code, parses the information (including a url
for a thumbnail image) and displays the results.
I am using threads, since the program will appear to freeze while
|
by: Tim |
last post by:
The are 2 threads - main thread and worker thread. The main thread
creates the worker thread and then the worker thread runs in an infinite
while loop till it is asked to exit by setting an event. The worker thread
instantiates an object and calls methods of that object. If some method call
fails, the main thread needs to be notified about the failure. What
mechanisms exist for notifying the main thread about the worker thread's
status -...
|
by: seattleboatguy |
last post by:
I am trying to send a message from a visual c++ user-thread to the main
window, so the main window can update text on the window to reflect
what the user-thread is doing. I have tried 2 different approaches, and
both fail. I don't know what to try next.
+++++++++++++++++++++++++++++++++++++++++++++++++++++
APPROACH #1: (this approach makes the most sence to me)
Configure the first parameter of the thread's PostMessage() to talk to
the...
|
by: Tomaz Koritnik |
last post by:
Is it possible to asynchronously call a method from worker thread so that
this method would execute in main-thread? I'm doing some work in worker
thread and would like to report progress to main thread to update some
controls. But I'd like to do that asynchronously so that worker thread would
not block until main thread finished updating and refreshing controls which
take some time. Using invoke is out since it blocks worker thread until...
|
by: Pixel.to.life |
last post by:
Dear All,
Here is a problem I am facing (it might be too simple, but then I
admit I am not a Guru:-)
I have a main thread, in managed C++, that deals with displaying a
form and some controls.
I invoke another thread for some processing from this thread, so
basically the main thread is waiting on the sub thread.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |