Java Concurrency Flashcards
What is a process?
A unit of execution that has its own memory space.
What is a thread?
A unit of execution within a process. Each process can have multiple threads. Each process or application has at least one thread, the main thread.
Why are threads important?
Creating a thread doesn’t require as many resources are creating a process. Every thread created by process shares the process’s memory . This can create problems.
What is multi-threading?
Running multiple processes at the same time. How to sinc the operations. Most oftentimes it is done at the same time.
What are the two ways of multi-threading?>
1- Can extend the thread class 2- implementing the runnable interface
Brief explanation of a thread
Basically a thread will allow one of the processes to run without having it synched up and will allow other threads to run.
What is one way to describe multi threading?
There are typically many applications running at the same time and having multiple tabs open and can run at the same time. And not have to wait for one to finish then have another one start.
One more description of multi threading
Multithreading is when multiple lines of code are running at the same time.
What is synchronization?
It is when multiple threads share the same state in a variable.
How do you make programs thread safe?
Need to make the it autonomous or synchronized block. Need to make a synchronized block. and define the prt of the code to be synchronized and is called a lock.