Concurrent Programming Basics
Threads and Synchronization
Thread Cooperation
Networking Essentials
Sockets and Proxies
100

What is the term for an instance of a running application?

Process

100

What keyword in Java is used to prevent multiple threads from running critical code simultaneously?

synchronized

100

What do you call a shared variable accessed by multiple threads?

Shared Resource

100

What do we call a 32-bit identifier assigned to a device on a network?

IP Address

100

In TCP networking, what class does the client use to connect to a server?

Socket

200

What do we call a lightweight subprocess sharing memory space with other threads?

Thread

200

What exception must be handled when calling Thread.sleep()?

InterruptedException

200

What is it called when multiple threads simultaneously modify shared data unpredictably?

Race Condition

200

What system translates hostnames to IP addresses?

DNS

200

What Java class waits for incoming TCP connections?

Server Socket 

300

What small unit of time is a thread given by the CPU to execute?

Time Slice

300

What method allows one thread to wait for another to complete?

join()

300

What is a code section that accesses shared resources and must not be concurrently executed by multiple threads?

Critical Region

300

What protocol guarantees reliable, ordered delivery?

TCP

300

Which UDP class represents a single message to be sent or received?

DatagramPacket

400

What component decides which process or thread gets CPU time?

Scheduler

400

What do we call unexpected output due to the unpredictable scheduling of multiple threads?

Interleaving

400

What three methods allow threads to pause and wait for notifications?

wait(), notify(), notifyAll()

400

What is the default hostname and ip address for the local machine?

localhost & 127.0.0.1

400

What design pattern allows a client to call methods on a server as if they were local?

Proxy Pattern

500

What Java method checks if a thread has started but not finished?

isAlive()

500

What are the four conditions that must be fulfilled to get a Deadlock?

  • Mutual Exclusion: A resource is only held by one thread at a time.

  • Hold and Wait: Threads hold one lock while waiting for another.

  • No Preemption: Locks can’t be forcibly removed.

  • Circular Wait: A cycle of threads, each waiting for the next.

500

In the Producer-Consumer pattern, what method is called if a consumer finds the queue empty? What is called if work is added to the queue?

Consumers call wait() if the queue is empty, Producers call notify() or notifyAll() when work is added.

500

In networking models, what are the 4 layers of the TCP/IP model?

Application → Transport → Internet → Network Access.

500

Write code to read & write from a socket stream.

PrintWriter out = new PrintWriter(socket.getOutputStream());

out.println("Hello"); out.flush();

Scanner in = new Scanner(socket.getInputStream());

System.out.println(in.nextLine());

M
e
n
u