Skip to content

Commit c4b15bf

Browse files
committed
Migrate development environment from Windows to macOS and continue project updates
- Shifted primary development environment from Windows to macOS to ensure better performance, stability, and streamlined workflow for Java development. - Removed OS-specific metadata and ensured platform-agnostic project compatibility. - Normalized line endings to LF for cross-platform consistency. - Verified and adjusted file paths, permissions, and encoding settings to suit macOS environment. - Cleaned up unnecessary Windows-generated files and updated Git configuration accordingly. - Future commits and development will now be managed entirely from macOS. This migration ensures a cleaner, more consistent setup moving forward and prepares the project for scalable development across Unix-based systems. Future development will continue on macOS for a smoother, Unix-based experience. Signed-off-by: Someshdiwan <[email protected]>
1 parent 948edff commit c4b15bf

13 files changed

+878
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/Section27NetworkProgramming" isTestSource="false" />
7+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
8+
<sourceFolder url="file://$MODULE_DIR$/JAVA8" isTestSource="false" />
9+
</content>
10+
<orderEntry type="inheritedJdk" />
11+
<orderEntry type="sourceFolder" forTests="false" />
12+
</component>
13+
</module>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Popular interview question: What is the difference between Process and Thread?
2+
3+
To better understand this question, let’s first take a look at what is a Program. A Program is an executable file containing a set of instructions and passively stored on disk. One program can have multiple processes. For example, the Chrome browser creates a different process for every single tab.
4+
5+
A Process means a program is in execution. When a program is loaded into the memory and becomes active, the program becomes a process. The process requires some essential resources such as registers, program counter, and stack.
6+
7+
A Thread is the smallest unit of execution within a process.
8+
9+
The following process explains the relationship between program, process, and thread.
10+
11+
The program contains a set of instructions.
12+
13+
The program is loaded into memory. It becomes one or more running processes.
14+
15+
When a process starts, it is assigned memory and resources. A process can have one or more threads. For example, in the Microsoft Word app, a thread might be responsible for spelling checking and the other thread for inserting text into the doc.
16+
17+
Main differences between process and thread:
18+
19+
Processes are usually independent, while threads exist as subsets of a process.
20+
21+
Each process has its own memory space. Threads that belong to the same process share the same memory.
22+
23+
A process is a heavyweight operation. It takes more time to create and terminate.
24+
25+
Context switching is more expensive between processes.
26+
27+
Inter-thread communication is faster for threads.
28+
29+
Over to you:
30+
31+
Some programming languages support coroutine. What is the difference between coroutine and thread?

Process vs Thread.gif

484 KB
Loading

Progressive Web App (PWA).txt

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
Absolutely! The `sw.js` file (short for **Service Worker**) is the **brain behind a Progressive Web App (PWA)**. It's a JavaScript file that your browser runs in the background — separate from the main page — and gives your site **offline capabilities, background sync, and faster performance through caching**.
2+
3+
---
4+
5+
## 🧠 In Simple Terms:
6+
Think of `sw.js` as your site’s **“offline assistant”**.
7+
Even if your user loses internet, the service worker helps show pre-cached pages and assets.
8+
9+
---
10+
11+
## 🔧 What `sw.js` Typically Does:
12+
13+
| Function | Description |
14+
|---------|-------------|
15+
| **Install** | Runs once when the service worker is registered. It's used to cache important assets. |
16+
| **Activate** | Cleans up old caches and takes control of pages. |
17+
| **Fetch** | Intercepts network requests and serves from cache (if available), otherwise from network. |
18+
| **Sync** *(optional)* | Used for background syncing when a user goes offline and comes back later. |
19+
| **Push** *(optional)* | Handles push notifications if integrated with a backend/server. |
20+
21+
---
22+
23+
## 🛠️ Example Use Cases:
24+
25+
1. **Offline Support**
26+
- Cache HTML, CSS, JS, and images.
27+
- When offline, the service worker can show cached content.
28+
29+
2. **Speed Boost**
30+
- Load from cache instead of waiting for the network = faster performance.
31+
32+
3. **App Shell Model**
33+
- Load static parts of the site immediately, then fetch dynamic parts.
34+
35+
---
36+
37+
## ✍️ Your current `sw.js` (simplified):
38+
39+
```js
40+
self.addEventListener("install", function (e) {
41+
console.log("Service Worker Installed");
42+
});
43+
44+
self.addEventListener("fetch", function (e) {
45+
// Just lets all requests go through as normal (no caching yet)
46+
});
47+
```
48+
49+
This just logs install and allows fetch requests.
50+
→ No caching or offline functionality yet.
51+
52+
/*
53+
const cacheName = 'java-evolution-cache-v1';
54+
const assetsToCache = [
55+
'/',
56+
'/JavaEvolution-Learning-Growing-Mastering/index.html',
57+
'/JavaEvolution-Learning-Growing-Mastering/assets/style.css',
58+
'/JavaEvolution-Learning-Growing-Mastering/assets/script.js',
59+
// Add more files as needed
60+
];
61+
62+
self.addEventListener("install", (event) => {
63+
event.waitUntil(
64+
caches.open(cacheName).then((cache) => cache.addAll(assetsToCache))
65+
);
66+
});
67+
68+
self.addEventListener("fetch", (event) => {
69+
event.respondWith(
70+
caches.match(event.request).then((response) => response || fetch(event.request))
71+
);
72+
});
73+
*/
74+
75+
/*
76+
self.addEventListener("install", function (e) {
77+
console.log("Service Worker Installed");
78+
});
79+
80+
self.addEventListener("fetch", function (e) {
81+
// Just let requests pass through for now
82+
});*/
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
2+
/*
3+
const cacheName = 'java-evolution-cache-v1';
4+
const assetsToCache = [
5+
'/',
6+
'/JavaEvolution-Learning-Growing-Mastering/index.html',
7+
'/JavaEvolution-Learning-Growing-Mastering/assets/style.css',
8+
'/JavaEvolution-Learning-Growing-Mastering/assets/script.js',
9+
// Add more files as needed
10+
];
11+
12+
self.addEventListener("install", (event) => {
13+
event.waitUntil(
14+
caches.open(cacheName).then((cache) => cache.addAll(assetsToCache))
15+
);
16+
});
17+
18+
self.addEventListener("fetch", (event) => {
19+
event.respondWith(
20+
caches.match(event.request).then((response) => response || fetch(event.request))
21+
);
22+
});
23+
*/
24+
25+
/*
26+
self.addEventListener("install", function (e) {
27+
console.log("Service Worker Installed");
28+
});
29+
30+
self.addEventListener("fetch", function (e) {
31+
// Just let requests pass through for now
32+
});*/
33+
34+
35+
36+
Absolutely! The `sw.js` file (short for **Service Worker**) is the **brain behind a Progressive Web App (PWA)**. It's a JavaScript file that your browser runs in the background — separate from the main page — and gives your site **offline capabilities, background sync, and faster performance through caching**.
37+
38+
---
39+
40+
## 🧠 In Simple Terms:
41+
Think of `sw.js` as your site’s **“offline assistant”**.
42+
Even if your user loses internet, the service worker helps show pre-cached pages and assets.
43+
44+
---
45+
46+
## 🔧 What `sw.js` Typically Does:
47+
48+
| Function | Description |
49+
|---------|-------------|
50+
| **Install** | Runs once when the service worker is registered. It's used to cache important assets. |
51+
| **Activate** | Cleans up old caches and takes control of pages. |
52+
| **Fetch** | Intercepts network requests and serves from cache (if available), otherwise from network. |
53+
| **Sync** *(optional)* | Used for background syncing when a user goes offline and comes back later. |
54+
| **Push** *(optional)* | Handles push notifications if integrated with a backend/server. |
55+
56+
---
57+
58+
## 🛠️ Example Use Cases:
59+
60+
1. **Offline Support**
61+
- Cache HTML, CSS, JS, and images.
62+
- When offline, the service worker can show cached content.
63+
64+
2. **Speed Boost**
65+
- Load from cache instead of waiting for the network = faster performance.
66+
67+
3. **App Shell Model**
68+
- Load static parts of the site immediately, then fetch dynamic parts.
69+
70+
---
71+
72+
## ✍️ Your current `sw.js` (simplified):
73+
74+
```js
75+
self.addEventListener("install", function (e) {
76+
console.log("Service Worker Installed");
77+
});
78+
79+
self.addEventListener("fetch", function (e) {
80+
// Just lets all requests go through as normal (no caching yet)
81+
});
82+
```
83+
84+
### 🔍 This just logs install and allows fetch requests.
85+
→ **No caching or offline functionality yet.**
86+
87+
---
88+
89+
Let me know if you're ready to upgrade it to support **actual caching**, and I’ll guide you step by step or give you a clean caching-enabled version!

0 commit comments

Comments
 (0)