This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python manage.py startapp blog |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python manage.py runserver |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OS_Critical_Section_Solution { | |
public static void main(String[] args) { | |
boolean[] flag = new boolean[2]; // flag[0] -> Process A, flag[1] -> Process B | |
// Strict Alternation | |
int cnt = 0; | |
while(true) { | |
flag[0] = true; | |
while (flag[1]==true); | |
System.out.println("V"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dataStructure; | |
public class CustomLinkedList<E> { | |
// Linked List Node | |
private CustomNode<E> head; // head node | |
private CustomNode<E> tail; // tail node | |
private int size; | |
public int size() { | |
return size; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.function.BinaryOperator; | |
public class MethodReferencesExamples { | |
public static <T> T mergeThings(T a, T b, BinaryOperator<T> merger) { | |
return merger.apply(a, b); | |
} | |
public static String appendStrings(String a, String b) {return a+b;} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. create a sub class inherent to Thread class | |
static class MyThread extends Thread { | |
@Override | |
public void run() { | |
System.out.println("Hello : "+Thread.currentThread().getName()); | |
} | |
} | |
MyThread myThread = new MyThread(); | |
myThread.start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thread thread = new Thread(() -> { | |
try { | |
Thread.sleep(1000L); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
System.out.println("Thread : "+ Thread.currentThread().getName()); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thread newThread = new Thread(() -> { | |
while (true) { | |
System.out.println("Thread : "+ Thread.currentThread().getName()); | |
try { | |
Thread.sleep(2000L); | |
} catch (InterruptedException e) { | |
System.out.println("Exit!"); | |
return; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thread newThread = new Thread(() -> { | |
System.out.println("Thread : "+ Thread.currentThread().getName()); | |
try { | |
Thread.sleep(2000L); | |
} catch (InterruptedException e) { | |
System.out.println("Exit!"); | |
return; | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// new single thread created and managed by executor service | |
ExecutorService executorService = Executors.newSingleThreadExecutor(); | |
Callable<String> hello = () -> { | |
Thread.sleep(2000L); | |
return "Hello"; | |
}; | |
Future<String> submit = executorService.submit(hello); // callable object executed and falls asleep for 2 sec | |
System.out.println(submit.isDone()); // main thread keep running - 1 |