Hey Jim,
Thank you very much for taking the time and effort to study my listings!
To answer your question:
1. Yes I am trying to understand how I can create multi-threaded code.
The purpose of listing 1 and 2 is to investigate how I can created "single stand-alone" threads,
- that can be "launched" by a "mother program" (the launcher)
- which will run "for ever", once started
- which can be "remotely controlled" (started, pauzed and terminated) from outside the thread itself.
The purpose of listing 2 and 3 is to investigate how I can created
- "multiple producers" vrs a "single consumer" thread
- inter-thread communication mechanisms like..
-> How to check if the (other) thread alive?
-> How to check if the (other) thread is accessible for calling threads?
-> How the (other) thread can tell his environment that he is busy / free?
-> When to use an (every lasting) THREAD as consumer? vrs
-> When to use a (dead) OBJECT as consumer?
2. I also want to get "a good feeling. insight" with multi-threading programming on how and when to use the
various multithreaded communication and synchronization mechanisms like:
- (wait, notify) -------------------------------------------------------> producer, consumer scenario
- (wait, notify_all) ----------------------------------------------------> producer, consumer
- calling synchronized {blocks of code}----------------------------> multiple threads with 1 (or more) shared object
- calling {entire methods} from one thread to another thread -->multiple threads with 1 (or more) shared object
in what kind of different scenarios.
I have read (and played with) lots of code examples from books like:
- Concurrency examples" - Sun Microsystem own tutorial
- "Concurrency: State Models & Java Programs" - J Kramer, J Magee (the best book for me so far!!)
- "Java threads 2nd edition" - O Reilly
- "Multi-threaded programming with java technology" - Sun Press
- "Java thread programming" - Sams
- "Java Concurrency in Practice" - Brian Goetz
- "Inside the Java Virtual machine" - Bill Venners
- "Thinking in Java" - Bruce Eckel
And numerous online tutorials, downloadable code examples and education materials i could find like
Jakob Jenkov - Java Concurrency tutorials -
http://tutorials.jenkov.com/java-concurrency/index.html
As you can see i have used all kind of different sources on Java multi-threading technologies, to from a clear picture on when to use what technology in which situation...
The reason I asked my question is that i have a "gut feeling" that i can solve this current challenge ALSO with Wait, Notify (since it is a producer, consumer scenario,
pattern) right... but i have not exactly figured out how.... and that is why i need a little help in modifing listing 2 (for the wait) and 3 (fro the notify, notify all) statement to be injected