Home > Back-end >  Java concurrency is what mean
Java concurrency is what mean

Time:10-12

Multithreading is colleagues or wheel

CodePudding user response:

Based on the amount of nuclear CPU,
If it is a single CPU, is the time slicing, multiple threads, in turn, use a small piece, like have a bottle of wine to mouth blown, a few people to blow, blow, each wheel to the
If multicore, how much is the bottle of wine, cocktail party in more than one person can drink a toast at the same time

CodePudding user response:

Single-core or serial, actually you just feel multithreading is parallel

CodePudding user response:

refer to the original poster m0_46343601 response:
is multithreaded colleagues or round the


Concurrency is a single-core multi-threaded operation, take turns to switch to use period, because the switching speed quickly, you feel like running at the same time, so called concurrent,

CodePudding user response:

Concurrent relative to a Java program is running together, but for the CPU core, at the same time can only run a process

On the macro is running at the same time, micro level, each CPU kernel is serialized

CodePudding user response:

For example, suppose that the memory a variable defined in n=10; Now two threads are executing n - operation, their complete 5 times, if there is no concurrency issues, then eventually n values should be 0.
Concurrent execution, for n - not atomic operations (what is atomic operation, to know), when a thread executing a n, first remove the 10 for minus one operation (can be thought of as the half still unfinished), thread 2 also perform n - operation at this moment, when the thread 2 see n or 10, when two threads are performed minus one after the operation, after the result is 9, two threads are give n 9 to assignment, so n is 9, there is a complicated problem, the solution is to n - lock, only when a thread to allow another thread to perform after,

CodePudding user response:

reference 1/f, restart response:
based on the amount of nuclear CPU,
If it is a single CPU, is the time slicing, multiple threads, in turn, use a small piece, like have a bottle of wine to mouth blown, a few people to blow, blow, each wheel to the
If multicore, how much is the bottle of wine, cocktail party in more than one person can drink a toast at the same time the

Multi-core is also a bottle of wine, only everyone took turns to blow speed is very fast, is take turns to blow you almost feel not to come out, like a person for everyone, but in any case, every instantaneous can only process one CPU time slice, the content of the multi-core just switching speed is very fast, so let a person feel multiple threads at the same time, multi-core, a bit like a crab, leg has a lot of, but only one mouth,

CodePudding user response:

Concurrency is a context switch, generally refers to on a CPU, parallel comparison was multicore, usually said the atomicity of refers to the concurrent operation, can be understood as not clock interrupt response and parallel atomic operation I don't understand, cheat myself: a CPU lock the address bus when atomic operation, so the resources won't appear inconsistent data

CodePudding user response:

refer to 6th floor Lv Xinyang response:
Quote: refer to 1st floor restart response:
based on the amount of nuclear CPU,
If it is a single CPU, is the time slicing, multiple threads, in turn, use a small piece, like have a bottle of wine to mouth blown, a few people to blow, blow, each wheel to the
If multicore, how much is the bottle of wine, cocktail party in more than one person can drink a toast at the same time the

Multi-core is also a bottle of wine, only everyone took turns to blow speed is very fast, is take turns to blow you almost feel not to come out, like a person for everyone, but in any case, every instantaneous can only process one CPU time slice, the content of the multi-core just switching speed is very fast, so let a person feel multiple threads at the same time, multi-core, a bit like crab legs are many, but only one mouth,



refer to 6th floor Lv Xinyang response:
Quote: refer to 1st floor restart response:
based on the amount of nuclear CPU,
If it is a single CPU, is the time slicing, multiple threads, in turn, use a small piece, like have a bottle of wine to mouth blown, a few people to blow, blow, each wheel to the
If multicore, how much is the bottle of wine, cocktail party in more than one person can drink a toast at the same time the

Multi-core is also a bottle of wine, only everyone took turns to blow speed is very fast, is take turns to blow you almost feel not to come out, like a person for everyone, but in any case, every instantaneous can only process one CPU time slice, the content of the multi-core just switching speed is very fast, so let a person feel multiple threads at the same time, multi-core, a bit like crab legs are many, but only one mouth,


You this was wrong, multi-core CPU can be executed in parallel, which at the same time multiple threads to perform at the same time,

CodePudding user response:

refer to the eighth floor hurtCat response:
Quote: refer to the sixth floor Lv Xinyang response:

Quote: refer to 1st floor restart response:
based on the amount of nuclear CPU,
If it is a single CPU, is the time slicing, multiple threads, in turn, use a small piece, like have a bottle of wine to mouth blown, a few people to blow, blow, each wheel to the
If multicore, how much is the bottle of wine, cocktail party in more than one person can drink a toast at the same time the

Multi-core is also a bottle of wine, only everyone took turns to blow speed is very fast, is take turns to blow you almost feel not to come out, like a person for everyone, but in any case, every instantaneous can only process one CPU time slice, the content of the multi-core just switching speed is very fast, so let a person feel multiple threads at the same time, multi-core, a bit like crab legs are many, but only one mouth,



refer to 6th floor Lv Xinyang response:
Quote: refer to 1st floor restart response:
based on the amount of nuclear CPU,
If it is a single CPU, is the time slicing, multiple threads, in turn, use a small piece, like have a bottle of wine to mouth blown, a few people to blow, blow, each wheel to the
If multicore, how much is the bottle of wine, cocktail party in more than one person can drink a toast at the same time the

Multi-core is also a bottle of wine, only everyone took turns to blow speed is very fast, is take turns to blow you almost feel not to come out, like a person for everyone, but in any case, every instantaneous can only process one CPU time slice, the content of the multi-core just switching speed is very fast, so let a person feel multiple threads at the same time, multi-core, a bit like crab legs are many, but only one mouth,


You this was wrong, multicore cpus can be executed in parallel, which at the same time multiple threads to perform at the same time,

I should be multithreaded mononuclear said
  • Related