Java Concurrency Flashcards

1
Q

What is a process?

A

A unit of execution that has its own memory space.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a thread?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why are threads important?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is multi-threading?

A

Running multiple processes at the same time. How to sinc the operations. Most oftentimes it is done at the same time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the two ways of multi-threading?>

A
1- Can extend the thread class
2- implementing the runnable interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Brief explanation of a thread

A

Basically a thread will allow one of the processes to run without having it synched up and will allow other threads to run.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is one way to describe multi threading?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

One more description of multi threading

A

Multithreading is when multiple lines of code are running at the same time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is synchronization?

A

It is when multiple threads share the same state in a variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you make programs thread safe?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly