简体   繁体   中英

Multiple Cores and java

I was just reading about "How does a server" handles multiple requests and ended up with java multithreading and multiple cores cpu.

During the days when the computers were single core and if there are 2 threads in java at the same time then jvm scheduler will take care of giving time to each thread. So, two threads never runs in parallel but makes use of ideal time (eg if a thread is blocked on some resource).

But is this is case with multiple cores and fork/join framework in java7 ? I mean i have heard that with multiple cores we can actually achieve parallelism. So, if i have two threads running, two cores cpu and each thread is given a separate core (it is not guaranteed though) then will they actually be parallel because jvm scheduler will still lead to time interleaving?

I am sorry if this question is stupid but i am really not sure on this one. Please help me to understand!!

Thanks! Ouney

The problem is that it is still very hard to understand how many threads, cores, ... are actually available.

My personal suggestion: there are several articles on the java specialist newsletter which do a very deep dive into this subject.

For example this one: http://www.javaspecialists.eu/archive/Issue135.html

or a very new, on "the number of available processors": http://www.javaspecialists.eu/archive/Issue220.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM