Threads and Processes

¡Supera tus tareas y exámenes ahora con Quizwiz!

What is a process?

A process has a self-contained execution environment with a complete and private set of run time instructions. Processes have their own memory space. Processes start from the primary thread and can spawn new threads if necessary.

What is a synchronized method?

A synchronized method only allows one thread access at a time, other threads are suspended until they gain access.

What is a thread?

A thread is a path of execution within a process. Threads share process resources, including memory and open files.

What is a thread join?

Allows one thread to wait for the execution of another to complete. The current thread will wait until the joined thread completes.

Why might one use a runnable over instantiating a new thread?

Classes only have to implement a runnable which means they can extend a subclass. While classes must extend the Thread class. Limiting functionality.

What are two basic strategies for using Thread objects to create a concurrent application?

Creating a Thread object or the use of an Executor.

What are two ways to create a Thread?

Creating a runnable and passing that into a thread, or creating a new thread class itself.

Define what IPC is and what it is used for.

Facilitating communication between processes, such as pipes or sockets. They can interact between processes on the same system and different systems.

How can synchronization be bad?

It can cause thread contention, when two or more threads access the same resource simultaneously. It can cause starvation and livelock.

How can processes interact?

Processes can interact through the use of IPC resources.

What is the difference between a synchronized method and statement?

Synchronized statements allow a method to lock certain portions of code whereas an entire method would be locked. Synchronized methods require that the object that has the lock to be specified. synchronized(this)

What is an InterruptedException?

This is an exception that sleep throws when another thread interrupts the current thread while sleep is active.

What is a thread interrupt and why use it?

Thread interrupts are used to inform a thread to stop what's it's doing and do something else. In most cases, terminating the thread is the use.

What is used to make processor time available to other threads?

Thread.sleep

What is the difference between a thread and a process?

Threads exist within a process, every process must have one. Threads share resources and memory space while processes run in separate memory spaces.

What is thread synchronization?

Used to solve the problem that communication between threads has for both thread interference and memory consistency errors.

What is a concurrent modification exception?

When a thread attempts to access data being used by another thread that is not thread-safe. Concurrent Collections are thread safe, like ConcurrentMap.


Conjuntos de estudio relacionados

Alice Paul, the suffrage Movement, & the Passage of the 19th Amendment

View Set

Radioactive Decay, Nuclear Reactions

View Set

Economics - 4.1.2, 4.1.3, 4.1.4 - Trade - A Level

View Set

Physci 167- Chapter 6: obesity-associated common diseases of western civilization, diabetes, heart disease and cancer// chapter 7- biology of food choice and addition, hidden clues.

View Set

Lecture 5: Haplorhini, Part 1: Tarsiers and Platyrrhines

View Set