https://github.com/dougeverly/delayedthread
DelayedThread constructs threads with delayed execution.
https://github.com/dougeverly/delayedthread
Last synced: about 1 month ago
JSON representation
DelayedThread constructs threads with delayed execution.
- Host: GitHub
- URL: https://github.com/dougeverly/delayedthread
- Owner: DougEverly
- Created: 2013-07-03T23:49:46.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2013-07-04T13:49:27.000Z (about 13 years ago)
- Last Synced: 2025-01-04T05:43:05.248Z (over 1 year ago)
- Language: Ruby
- Size: 105 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
DelayedThread
=============
DelayedThread constructs threads with delayed execution.
Usage
-----
```ruby
d = DelayedThread.new
# Add a delayed thread
d.delayed_thread do
5.times do |x|
puts x.to_s
sleep 1
end
end
# Add another delayed thread
d.delayed_thread do
5.times do |x|
puts (x * 2).to_s
sleep 1
end
end
# wait some time
sleep 2
# start delayed thread execution
d.start
# join delayed threads
d.join
```
Do not delay threads
```ruby
d.delayed = false
```
Get list of delayed threads
```ruby
d.threads # => Array
```