Concurrency Flashcards

1
Q

Performing two or more tasks at the same time

A

Multitasking

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

Two or more programs run in parallel (or
concurrently)

A

Multiprocessing

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

One program that performs two or more tasks
(threads) at the same time

In thread-based multitasking, multiple threads
(multiple parts of one program) run concurrently

A

Multithreading

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

a programming practice where more than one thread
runs within a program or process.

A

Multithreading

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

Types of Multitasking

A

Multiprocessing & Multithreading

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

Every running
application has at least one thread, the ______________.

A

main thread

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

T or F:

Threads share the process’ resources, including
memory and open files.

A

T

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

A thread that is started and waiting to be executed

A

Ready State

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

A thread is being executed

A

Running State

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

5 States of a Thread

A

Ready, Running, Suspended, Blocked, Terminated

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

Execution is paused and can be resumed where it left
off

A

Suspended

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

Thread is waiting for a request (I/O) to be completed or a resource cannot be accessed because it is being
used by another thread

A

Blocked

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

Execution is stopped and cannot be resumed

A

Terminated

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

Commonly Used Thread Methods

A

getName(), run(), sleep(), start(), join(), getPriority()

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

Thread method that Suspends the thread; enables you to specify the period the thread is suspended

A

sleep();

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

the entry point into the thread

A

run();

17
Q

Waits for the thread to die/finish

A

join();

18
Q

All implementing classes of runnable or those that extends the thread class must override this method.

A

run();

19
Q

2 Ways to create a Thread

A

Extending Thread class;

Kart extends Thread;

Implementing Runnable

Kart extends Runnable

Thread myKart = new Thread(new Kart(constructor));

20
Q

In Java, we use the _______________ keyword to lock a critical section.

A

synchronized

21
Q

A major concern in multithreading is when two or more
threads share the same resource. Only one of them
should access the resource at one time to avoid ___________________________.

A

data
consistency errors

22
Q

In Java, the keyword _________________ is used to limit the access (obtain lock) to a resource (object) to just one thread.

A

synchronized

23
Q
A