Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
(dorun (pmap f (range 1 1001)))
f = fn x -> x * :rand.uniform() end
tasks = Enum.map(1..1000, fn i ->
Task.async(fn ->
f.(i)
end)
end)
results = Task.yield_many(tasks, :infinity)
# Optional, if you care for the result
IO.inspect Enum.map(results, fn {_, {:ok, val}} -> val end)
lists:foreach(fun(I) -> spawn(?MODULE, _f, [I]) end, lists:seq(1, 1000)).
integer :: tasks, n, t, i
tasks = 1000
n = num_images()
t = this_image()
do i = t, tasks, n
call f(i)
end do
sync all
for (let i = 1; i <= 1000; i++) setTimeout(() => f(i), 0);
type
TThreadF = class(TThread)
i: Integer;
constructor Create(const _i: Integer);
procedure Execute; override;
end;
constructor TThreadF.Create(const _i: Integer);
begin
i := _i;
FreeOnTerminate := True;
inherited Create(False);
end;
procedure TThreadF.Execute;
begin
f(i);
end;
var i: Integer;
begin
for i := 1 to 1000 do begin TThreadF.Create(i);
ReadLn;
end.
threads = 1000.times.map do |i|
Thread.new { f(i) }
end
threads.join