By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,470 Members | 1,907 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,470 IT Pros & Developers. It's quick & easy.

main thread

P: n/a
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.currentThread().wait();

Regards,

Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Hamed Seifoddini" <ha***@seifoddini.com> wrote in message
news:cc*********@news-dxb.emirates.net.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.currentThread().wait();

Define "work". "Thread.currentThread().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.
Jul 17 '05 #2

P: n/a
"Ryan Stewart" <zz********@gSPAMo.com> wrote in message news:<v6********************@texas.net>...
"Hamed Seifoddini" <ha***@seifoddini.com> wrote in message
news:cc*********@news-dxb.emirates.net.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.currentThread().wait();

Define "work". "Thread.currentThread().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.
Jul 17 '05 #3

P: n/a
Hi,

In simple Thread.wait(); should work,

Thread.currentThread.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***@seifoddini.com> wrote in message news:<cc*********@news-dxb.emirates.net.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.currentThread().wait();

Regards,

Jul 17 '05 #4

P: n/a

"Giridhar Nandigam" <na********@yahoo.com> wrote in message
news:42**************************@posting.google.c om...
Hi,

In simple Thread.wait(); should work,

Thread.currentThread.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***@seifoddini.com> wrote in message

news:<cc*********@news-dxb.emirates.net.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.currentThread().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.

Jul 17 '05 #5

P: n/a
na********@yahoo.com (Giridhar Nandigam) wrote in message news:<42**************************@posting.google. com>...
Hi,

In simple Thread.wait(); should work,
Thread.wait() doesn't work, since wait() is non-static method,
Thread.class.wait() 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?
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.