Fork me on GitHub
#core-async
<
2019-08-09
>
Anik Chowhdury03:08:38

I have used future for multhreading in core-async. Here is the screenshot of my code and error message. I got null pointer exception for using future. If i use just

(async/thread-call (process-data-chan))
instead of
(future (async/thread-call (process-data-chan)))
i dont get any null pointer exception. Can anyone explain me and give me solution about this? I am newbie in clojure and specially in multi threading.

hiredman03:08:29

Neither of those is correct

❤️ 4
hiredman03:08:19

Calling thread or thread-call like that in a future is making a new thread in a new thread

hiredman03:08:50

thread-call takes a function and you are passing it nil

hiredman03:08:04

The result of calling your function

hiredman03:08:37

thread is the macro like future

hiredman03:08:21

Replacing future with thread is pointless unless you are using go blocks which need to park in the result, the both just run whatever on a thread pool, no difference except the return value which doseq throws away