Skip to content

Instantly share code, notes, and snippets.

View HWilliamgo's full-sized avatar
🥳
to be happy when coding

HWilliamgo

🥳
to be happy when coding
View GitHub Profile
Java 29 hrs 6 mins ███████████████▏░░░░░ 72.5%
Groovy 3 hrs 49 mins ██░░░░░░░░░░░░░░░░░░░ 9.5%
C 3 hrs 37 mins █▉░░░░░░░░░░░░░░░░░░░ 9.0%
Text 1 hr 5 mins ▌░░░░░░░░░░░░░░░░░░░░ 2.7%
Bash 36 mins ▎░░░░░░░░░░░░░░░░░░░░ 1.5%
@HWilliamgo
HWilliamgo / dynamic_cond_and_mutex.cpp
Last active October 2, 2021 06:40
[pthread多线程]描述生产者消费者模型 #C #多线程
pthread_cond_t *condv = nullptr;
pthread_mutex_t *mlock = nullptr;
static data *phead = nullptr;
static void initLock() {
condv = new pthread_cond_t;
mlock = new pthread_mutex_t;
pthread_mutex_init(mlock, nullptr);
pthread_cond_init(condv, nullptr);
@HWilliamgo
HWilliamgo / main.cpp
Last active October 1, 2021 07:12
[C随机数]#C
/**
* 在[range]范围内生成一个正的随机数
* @param range 范围
* @return 随机数
*/
static int randomNum(int range) {
// 用当前时间戳生成随机数种子
time_t seed = time(0);
// 将随机数种子填写到随机数生成器里面
srand(seed);
@HWilliamgo
HWilliamgo / Main.kt
Created May 20, 2022 03:43
[Kotlin elvis] #Kotlin
object StringProducer {
fun produce(): String? {
return "abc"
}
}
fun main() {
StringProducer.produce()?.let {
println(it)
} ?: run {