multithreading - Does Java have support for multicore processors/parallel processing? -
i know processors have 2 or more cores, multicore programming rage. there functionality utilize in java? know java has thread class, know around long time before multicores became popular. if can make use of multiple cores in java, class/technique use?
does java have support multicore processors/parallel processing?
yes. has been platform other programming languages implementation added "true multithreading" or "real threading" selling point. g1 garbage collector introduced in newer releases makes use of multi-core hardware.
java concurrency in practice
try copy of java concurrency in practice book.
if can make use of multiple cores in java, class/technique use?
java.util.concurrent
utility classes commonly useful in concurrent programming. package includes few small standardized extensible frameworks, classes provide useful functionality , otherwise tedious or difficult implement. here brief descriptions of main components.
executors
executor
simple standardized interface defining custom thread-like subsystems, including thread pools, asynchronous io, , lightweight task frameworks.
queues
the java.util.concurrent concurrentlinkedqueue
class supplies efficient scalable thread-safe non-blocking fifo queue.
timing
the timeunit
class provides multiple granularities (including nanoseconds) specifying , controlling time-out based operations. classes in package contain operations based on time-outs in addition indefinite waits.
synchronizers
four classes aid common special-purpose synchronization idioms. semaphore
classic concurrency tool. countdownlatch
simple yet common utility blocking until given number of signals, events, or conditions hold. [...]
concurrent collections
besides queues, package supplies few collection implementations designed use in multithreaded contexts: concurrenthashmap
, copyonwritearraylist
, , copyonwritearrayset
.
this comes in handy if want match number of threads number of available cpus example:
int n = runtime.getruntime().availableprocessors();
Comments
Post a Comment