Skip to content

Instantly share code, notes, and snippets.

View Ghosttrio's full-sized avatar
๐Ÿฅ‹
Learning

Changsoon Ghosttrio

๐Ÿฅ‹
Learning
View GitHub Profile
@Ghosttrio
Ghosttrio / 20240105-2.java
Created January 5, 2025 06:36
20240105-2.java
public class SharedResource {
static class Resource implements Runnable {
private int instanceField = 0;
private static int staticField = 0;
@Override
public synchronized void run() {
instanceField++;
staticField++;
@Ghosttrio
Ghosttrio / 20250105-1.java
Last active January 5, 2025 06:36
20250105-1.java
public class LocalVariable {
static class MyThread extends Thread {
@Override
public void run() {
int local = 0;
local++;
System.out.println("์Šค๋ ˆ๋“œ ์ด๋ฆ„: " + Thread.currentThread().getName() + " ์Šค๋ ˆ๋“œ์˜ ์ง€์—ญ ๋ณ€์ˆ˜ : " + local);
}
}
@Ghosttrio
Ghosttrio / 20241223-2.bash
Created December 30, 2024 05:40
20241223-2.bash
chmod +x gradlew
@Ghosttrio
Ghosttrio / 20241223-1.bash
Created December 30, 2024 05:40
20241223-1.bash
/files/test.csv //์ƒ๋Œ€๊ฒฝ๋กœ
classpath:/files/test.csv
@Ghosttrio
Ghosttrio / 20241230-3.java
Created December 30, 2024 05:38
20241230-3.java
List<String> list = resource.stream.collect(Collectors.toList());
// ๋” ๊ฐ„๊ฒฐํ•จ
List<String> list = resource.stream.toList();
@Ghosttrio
Ghosttrio / 20241230-2.java
Created December 30, 2024 05:38
20241230-2.java
List<String> list = stream.collect(Collectors.toList());
Set<String> set = stream.collect(Collectors.toSet());
Map<Integer, String> map = stream.collect(Collectors.toMap(String::length, Function.identity()));
@Ghosttrio
Ghosttrio / 20241230-1.java
Created December 30, 2024 05:37
20241230-1.java
<T, A, R> R collect(Collector<? super T, A, R> collector);
/**
* T: ์ŠคํŠธ๋ฆผ์˜ ์š”์†Œ ํƒ€์ž…
* A: ์ˆ˜์ง‘ ๊ณผ์ •์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๋‚ด๋ถ€ ์ƒํƒœ ํƒ€์ž…
* R: ์ตœ์ข…์ ์œผ๋กœ ์ƒ์„ฑ๋˜๋Š” ๊ฒฐ๊ณผ ํƒ€์ž…
*/
@Ghosttrio
Ghosttrio / 20241209-3.kt
Created December 6, 2024 01:41
20241209-3.kt
class Box<T>(val value: T)
class Dog : Animal()
open class Animal
fun addBoxContent(box: Box<Dog>) {
val animalBox: Box<Animal> = box // ์˜ค๋ฅ˜ ๋ฐœ์ƒ
}
@Ghosttrio
Ghosttrio / 20241209-2.kt
Created December 6, 2024 01:41
20241209-2.kt
class Cat : Animal()
open class Animal
class Consumer<in T> {
fun consume(item: T) {
println(item)
}
}
fun main() {
@Ghosttrio
Ghosttrio / 20241209-1.kt
Created December 6, 2024 01:40
20241209-1.kt
fun main() {
val dogs: List<Dog> = listOf(Dog(), Dog())
val animals: List<Animal> = dogs
printList(animals)
}
open class Animal
class Dog : Animal()
class Cat : Animal()