ref: c5e5bff1d3e40c29b5084f4ed76b11b1ce1f7e90
parent: 5c482500316fb1964e64db9c42322b839dfc0606
	author: 0x4A4D00 <scorpion_rn@yahoo.com>
	date: Fri Jul 21 04:20:36 IDT 2023
	
Concurrent Async Tested also with HTTP Request
--- a/Test_Multi_Threading.rb
+++ b/Test_Multi_Threading.rb
@@ -1,5 +1,40 @@
require 'thread'
require 'concurrent'
+require 'async'
+require 'async/http/internet'
+
+class Echo
+ include Concurrent::Async
+
+ def echo(msg)
+ sleep(3)
+    print "#{msg}\n"+ end
+end
+
+horn = Echo.new
+horn.echo('zero')      # synchronous, not thread-safe+# returns the actual return value of the method
+
+horn.async.echo('one') # asynchronous, non-blocking, thread-safe+# returns an IVar in the :pending state
+
+horn.async.echo('two') # synchronous, blocking, thread-safe+# returns an IVar in the :complete state
+
+start = Time.now
+
+Async do |task|
+ http_client = Async::HTTP::Internet.new
+
+ task.async do
+    http_client.get("https://httpbin.org/delay/1.6")+ end
+
+end
+
+puts "Duration: #{Time.now - start}"+
executor = Concurrent::ThreadPoolExecutor.new(
min_threads: 2,
--
⑨