Article View: borland.public.jbuilder.java.language
Article #17377Java Wait and Notify - Advice?
From: Mark Beecroft
Date: Mon, 16 Nov 1998 00:00
Date: Mon, 16 Nov 1998 00:00
35 lines
1872 bytes
1872 bytes
The scenario is this: I am writting a JBuilder Java programme which creates an additional thread to deal with cryptography and various other issues (crypto thread). When the programme kicks off, the main thread is started as usual and proceeds until it hits a Wait() at which point the crypto thread takes over. Having completed the cryptographic methods, a Notify() is performed on the main thread which duly reaquires control (since both threads are the same priority, I assume). I assume the crypto thread is still available, but is simply not live. Now, I can continue Wait()ing and Notify()ing on the main thread in order to do processing in the crypto thread ad infinitum. The question is: what is the best way of doing this? It seems to be 'loose' programming to leave a thread hanging in this way while the main thread is processing! I have looked at Wait()s and Notify()s on the crypto thread itself, but I keep coming accross the situation whereby, if I do a Notify() on the main thread before the declaration of the Wait() on the crypto thread, the latter will never occur. Also, if it was essential to do a Wait() and Notify() on the crypto thread, how could this be best achieved? Previso: No thread priority altering please I hope I given enough information for you to get stuck in! Thanks in advance for you help. (Some examples would be much appreciated.) Mark B.
Technical Details
Message-ID:
<72pk2c$qiu21@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,8889eb48cc4dd825,start X-Google-Attributes: gidf74b3,public From: "Mark Beecroft" <mark.beecroft@twinsoft.co.uk> Subject: Java Wait and Notify - Advice? Date: 1998/11/16 Message-ID: <72pk2c$qiu21@forums.borland.com> X-Deja-AN: 412434303 Organization: Twinsoft Uk Ltd X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Newsgroups: borland.public.jbuilder.java.language