Or criterion, compile implement should obtain read / the use that keeps a lock:
Additionally one kind of method is (the method that this also is a kind of ideal)- - compile implement should use automatically to read / write a lock to come synchronous visit blame is changeless Static region, such, programmer need not worry about this problem.
The abrupt end of tiring-room line Cheng
After Cheng of all blame tiring-room line are stopped, tiring-room line Cheng is ended suddenly. Founded resource of a few overall situation when tiring-room line Cheng (for example a database joins or temporarily file) , these resource when stage line Cheng ends were not shut or delete after that can cause a problem.
To this problem, I suggest to draft regulation, make Java fictitious machine does not close applied process below following case: Cheng of any blame tiring-room line are moving, or: Any tiring-room line Cheng are carrying out code piece of Synchronized method or a Synchronized.
Tiring-room line Cheng carries out Synchronized in it piece or can be shut instantly after Synchronized method.
Introduce Stop() , Suspend() and Resume() key word afresh
As a result of practical matter this is unworkable perhaps, but I hope not to abolish Stop() (is in Thread and ThreadGroup) . But, I can change the semantics of Stop() , make when calling it, won't destroy already had code. But, about the problem of Stop() , remember please, after line Cheng is stopped, stop() will release all locks, the line Cheng that so likely and potential ground makes working on this object enters a kind to be not stabilized (local revise) condition. Because inactive line Cheng already released all locks that it gets on in this object, so these objects can no more be visited.
To this problem, can the behavior of redefine Stop() , make line Cheng just is stopped instantly when having any locks only. If it is holding a lock, I suggest here line Cheng releases the last Suo Houcai to stop it. Can use to realize this deed with the mechanism that casts an unusual likeness. Cheng of line be stoppinged should set a mark, and should exit all synchronism piece when test this mark instantly. If set this mark, what throw a form of a concealed is unusual, but when answering to be able to be arrested to catch and end when line Cheng no longer, this won't generate any output unusually. Attention, the operating system cannot handle the NT of Microsoft well of an exterior directive balk (Abrupt) . (it does not notice a dynamic link library Stop message, so the likelihood causes the resource leak of systematic level. ) this is the reason that I suggest to use similar and unusual method to bring about Run() simply to return.
The real problem that brings with unusually similar processing technique with this kind is, you are indispensible in every Synchronized piece hind insert code to test “stopped” mark. And this is planted additional code can reduce systematic performance and increase code length. The another method that I think of is make Stop() realizes defer of a “ (Lazy)” stops, below this kind of circumstance, just stop when calling Wait() or Yield() next time. I still want to add an IsStopped() and Stopped() method to the middle of Thread (right now, thread will work like IsInterrupted() and Interrupted() , but can detect the condition) of “stop-requested” . This kind of method not to the first kind general in that way, but feasible and won't produce overload.
Previous 1 2 3 4 5 6 7 8 9 10 1112 13 Next