Concurrency Lecture 2 Flashcards

1
Q

How are thread groups organized together in the JVM?

A

As a tree structure.

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

What is the root thread group in the JVM?

A

The system thread group.

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

What threads groups are part of the JVM by default?

A

The system and main thread groups.

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

What is the code for creating a new thread group?

A

Not specify the parent, making Main the parent:

ThreadGroup A = new ThreadGroup(“A”);

Specify the parent (In this case, A) :

ThreadGroup B = new ThreadGroup(A, “B”)

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

What does it return if you look for the parent of the system thread group?

A

Null.

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

What happens if you don’t specify a parent for the thread group in declaration?

A

It’s parent gets set to Main by default.

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

What is race condition?

A

When two threads access the same data and change it at the same time. This can cause the data to be set to the wrong thing as both threads do not alter the data, only one will.

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

When does race condition occur?

A

What two threads try to access the same thread at once.

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

What does the thread scheduler do?

A

It runs the threads. Each thread is run for a short amount of time, and then the scheduler switches the active thread.
There is no guarantee that threads will run in the order they are started in.

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