feat: Add comprehensive examples from multithreading and hashing lectures

This commit is contained in:
2026-05-24 15:46:45 +03:30
parent 6583799d9e
commit 83746b88f6
13 changed files with 314 additions and 39 deletions
@@ -0,0 +1,35 @@
package lecture.multithreading.basics;
class WorkerTask implements Runnable {
@Override
public void run() {
System.out.println("👷 Worker started...");
try {
Thread.sleep(10000); // Runs for 10 seconds
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("👷 The worker finished his work!");
}
}
public class JoinSimpleExample {
public static void main(String[] args) {
WorkerTask task = new WorkerTask();
Thread worker = new Thread(task);
worker.setName("Worker-Thread");
worker.start();
System.out.println("The main thread waits until the worker finishes...");
try {
worker.join(); // The main thread stops here until the worker finishes
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Main thread continues - now that the worker is finished!");
}
}