Skip to content

Commit

Permalink
Merge pull request #1 from themantra108/themantra108-patch-1
Browse files Browse the repository at this point in the history
Add files via upload
  • Loading branch information
themantra108 authored Jun 1, 2023
2 parents f791c74 + f9e5f35 commit 801b49e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions b.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function task_function()
sleep(10)
end

function main()
# Check if the number of tasks is provided as a command line argument
if length(ARGS) < 1
println("Usage: julia concurrent_tasks.jl <num_tasks>")
return
end

# Get the number of tasks from the command line argument
num_tasks = parse(Int, ARGS[1])

# Spawn concurrent tasks
tasks = Vector{Task}(undef, num_tasks)
for i in 1:num_tasks
tasks[i] = @async task_function()
end

# Wait for all tasks to finish
for task in tasks
wait(task)
end

println("All tasks have finished.")
end

stats = @timed main()

0 comments on commit 801b49e

Please sign in to comment.