Suspend () is a run-time state that enters a blocking state (note that the lock flag is not released). Resume () when restoring state. Stop () means release all.
There are deprecated flags on these methods, which indicate that this method is not recommended for use.
In general, the Main method main () ends when the thread ends, but there may be situations where the thread needs to be interrupted. For multithreading in general, each thread is a loop, and if you break the thread we must find a way to get it out.
If the Main method main () wants to end a thread in a block (such as sleep or wait)
Then we can call interrupt () on the thread object from other processes. Used for blocking (or lock pooling) throws an exception interrupted Exception.
This exception causes the thread to break and execute the code in the catch.
Multi-Threading Focus: Two ways to implement multithreading, Synchronized, and producer and consumer issues (Producerconsumer.java files).
1 Package tomtexts;2 3Import java.util.*;4 classCounter {5 inti =1; 6 PublicString toString () {7 returninteger.tostring (i);8 }9 }Ten classtomtexts_23 { One Public Static voidMain (string[] args) { AHashtable HT =NewHashtable (); - for(inti =0; I <10000; i++) { - //produce a number between 0 and: theInteger r =NewInteger (int) (Math.random () * -)); - if(Ht.containskey (R)) -((Counter) Ht.Get(r)). i++; - Else +Ht.put (R,NewCounter ()); - } +System. out. println (HT); A } at}
In general, the Main method main () ends when the thread ends