Skip to content

Instantly share code, notes, and snippets.

View BadUncleX's full-sized avatar

BadUncle BadUncleX

View GitHub Profile

clojure atom实现缓存

@BadUncleX
BadUncleX / 00 [clojure promise vs deliver].md
Last active April 11, 2018 05:26
promise and deliver (also future)

promise vs future

reference: stackeroverflow

promise

  1. You create a promise. That promise object can now be passed to any thread.
  2. You continue with calculations. These can be very complicated calculations involving side-effects, downloading data, user input, database access, other promises – whatever you like. The code will look very much like your mainline code in any program.
  3. When you’re finished, you can deliver the results to that promise object.
  4. Any item that tries to deref your promise before you’re finished with your calculation will block until you’re done. Once you’re done and you’ve delivered the promise, the promise won’t block any longer.
@BadUncleX
BadUncleX / 00 [clojure delay用法].md
Last active April 11, 2018 05:27
delay用法 c3p0 线程池 thread pool 数据源 datasource

A Delay ensures that some code is either run zero or one time. It's run zero times if the Delay is never derefed.

Delays are also useful for a shared resource between threads.

@BadUncleX
BadUncleX / 00 [CountDownLatch 同步计数器实现运动员比赛模拟]
Last active April 11, 2018 05:28
CountDownLatch 同步计数器 运动员跑步比赛
CountDownLatch 同步计数器
@BadUncleX
BadUncleX / 00 [clojure future 用法]
Last active April 11, 2018 05:29
future 用法 (含有CountDownLatch) core.async alts!
future 用法
@BadUncleX
BadUncleX / 00 [clojure pcall 并发执行多个无参方法].md
Last active April 11, 2018 05:30
pcall 并发执行多个无参方法

pcall 并发执行多个无参方法

@BadUncleX
BadUncleX / 00 [clojure实现rss中的关键词统计].md
Last active August 5, 2019 02:13
rss中的关键词统计 来自joy of clojure clj

rss中的关键词统计

好消息, 死锁是确定性的.

@BadUncleX
BadUncleX / 00 [Executor线程池多次执行方法: 测试atom计数器].md
Last active April 11, 2018 05:34
Executor线程池多次执行方法: 测试atom计数器

Executor线程池多次执行方法: 测试atom计数器