Multi-Threading Flashcards

1
Q

What is a Thread in Java?

A

A thread in Java is an independent path of execution in an application. JVM gives
each thread its own method-call stack.

When we start JVM, Java starts one thread. This thread calls the main method of the class passed in argument to java call.

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

What is the priority of a Thread and how it is used in scheduling?

A

In Java, every Thread has a priority. This priority is specified as a number between 1 to 10.
Scheduler in Java schedules different threads based on the priority of a thread. It is also known as pre-emptive scheduling.

The thread with higher priority gets preference in execution over a thread with lower priority.

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

What is the default priority of a thread in Java?

A

In Java, a new thread gets the same priority as the priority of the parent thread that creates it.
Default priority of a thread is 5 (NORM_PRIORITY).

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

What are the three different priorities that can be set on a Thread in Java?

A
  1. MIN_PRIORITY: This is the minimum priority that a thread can have.
  2. NORM_PRIORITY: This is the default priority that is assigned to a thread.
  3. MAX_PRIORITY: This is the maximum priority that a thread can have.

Default priority of a thread is 5 NORM_PRIORITY. The value of
MIN_PRIORITY is 1 and the value of MAX_PRIORITY is 10.

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

What are the Four classes of computer architecture based on Instructions streams and Data Streams

A

SISD- Single Instruction Single data
SIMD- Single Instruction Multiple data
MISD - Multiple Instruction Single data
MIMD- Multiple Instruction Multiple data

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

What is SISD?

A

It only perfroms one series of Instruction and also act on one element of data at a time.
eg- A chief Chopping carrot

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

What is SIMD?

A

A parallel computer with multiple processing units. All processors execute the same Instruction but operate on different data element.

eg- Two chiefs chopping different things in sync.
Good for image processing

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

What is MISD?

A

Each processing unit independently process its own separate set of instructions. But all of the processors are working on a single data stream.

ps. doesn’t make practical sense

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

What is MIMD?

A

Every processing unit can be executing a different set of instructions and also all the operations can be done on a different set of data element.

eg- one chief peeling carrot the other chopping onions

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

What are the sub categories for the programming model of MIMD

A

SPMD- Single program multiple data

MPMD- Multiple program Multiple Data

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

What is SPMD?

A

Multiple processing units are executing a copy of the same single program simultaneously. However they can each use different data.

This is the most commonly used architecture

eg- Using same recipee

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

What is MPMD?

A

Processors can be executing different independent programs at the same time and also be operating on a different data

Not as common as SPMD

eg - using different data

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

What are the Memory Architectures?

A

Shared memory

Distributed memory

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

What is a shared memory?

A

It is a memory in which all processors access the same memory with global address space.

Whenever their is a change in a memory space, all the processors are updated of the change.

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

What are the different type of Shared memory architectures?

A

uniform memory access(UMA)

non uniform memory access(NUMA)

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

What is UMA?

A

Its a type of shared memory in which all of the processors have equal access to the memory

17
Q

What is SMP?

A
18
Q

What is the purpose of join() method in Thread class?

A