Concurrent Package offerred a series of basic operation port, include Sync, channel, executor, barrier, callable. Before here will be right 3 kinds of interface and its part derive kind have simple introduction.
Sync interface: Be in charge of synchronous operation technically, with the Synchronized key word that offers at replacing Java, in order to realize more agile code synchronism. Its kind the relation pursues as follows:

Graph 3 Concurrent wraps Sync interface kind concern plan
Semaphore: And in front introductory code is similar, can use at Pool kind limitation of implementation endowment source control. Offerred Acquire() method to allow to try a lock to decide semaphore inside set time, if return False overtime.
Mutex: The Synchronized with Java is similar, what differ to it is, the synchronism of Synchronized paragraph can restrict only inside a method, and Mutex object can serve as parameter to be delivered between the method, can enlarge synchronous code limits to cross a method to cross an object even so.
NullSync: One compares strange thing, the in-house implementation of its method is empty, the likelihood is if you are in,the author thinks actual in discover some paragraph of code to need not use synchronism at all, but do not want to alter too much again this paragraph of code, can replace original Sync example so with NullSync. In addition, because the method of NullSync is Synchronized, still preserved the character of ” of “ memory camp so.
ObservableSync: Rise Sync and Observer mode union, when the method of Sync is called, notice the person that subscribe to the message, can use at synchronous function to debug.
TimeoutSync: Can consider as an Adaptor, its construction function is as follows: Public TimeoutSync(Sync Sync, long Timeout){…}
The code of specific lock relies on the Sync example that tectonic function passes into to finish, the only responsible lock that monitor operates its oneself overtime, but as operable as SyncSet.
Channel interface: Have the container of synchro control ability on behalf of a kind, you can be deposited from which / read take a target. Unlike the Collection interface in JDK, can regarding Channel is the person that join object constructs (the person that Producer) and object are used (a conduit between Consumer) . If plan institute shows:

Graph 4 Concurrent includes Channel interface sketch map
Through cooperating with Sync interface, the target that Channel offerred block form accesses a method (Put/take) and the Offer/poll means that can set block latency time. Realize Channel interface kind have LinkedQueue, boundedLinkedQueue, boundedBuffer, boundedPriorityQueue, synchronousChannel, slot.

Graph 5 Concurrent wraps Channel interface ministry to classify a relation to pursue
Previous 1 2 3 4 5 67 8 Next