Interview questions-Java multithreading

Java multithreading

Multithreading basics

  1. Talk about the difference between concurrency and parallelism?

    • Concurrency: Refers to two or more events occurring in the same time interval. These events occurred at the same time on a macro level, but alternately occurred on a micro level.
    • Parallel: Two or more events occur at the same time at the same time.

    E.g:

    • Single-core CPU can only execute one program at the same time, and multiple programs can only be executed concurrently
    • Multi-core CPU can execute multiple programs at the same time, and multiple programs can be executed in parallel
  2. What are threads and processes?

    • Process is the basic operating unit managed by the operating system
    • A thread is a subtask that runs independently in a process
  3. Please briefly describe the relationship between threads and processes?

    There can be multiple threads in a process, and multiple threads share the process's heap and method area resources, but each thread has its own program counter, virtual machine stack, and local method stack.

    and so

Guess you like

Origin blog.csdn.net/bm1998/article/details/114239904