Skip to content

Instantly share code, notes, and snippets.

@ashbb
Created March 10, 2012 05:55
Show Gist options
  • Select an option

  • Save ashbb/2010465 to your computer and use it in GitHub Desktop.

Select an option

Save ashbb/2010465 to your computer and use it in GitHub Desktop.
Why doesn't a red rectangle appear within Thread block?
require 'java'
require 'swt'
module Swt
include_package 'org.eclipse.swt'
include_package 'org.eclipse.swt.widgets'
include_package 'org.eclipse.swt.graphics'
end
class Object
include Swt
end
display = Swt::Display.new
shell = Swt::Shell.new display
shell.setSize 300+16, 300+38
cs = Swt::Composite.new shell, Swt::SWT::NONE
cs.setSize 300, 300
shell.open
#Thread.new do
gc = Swt::GC.new cs
gc.setBackground Swt::Color.new(display, 255, 0, 0)
gc.fillRectangle 100, 100, 100, 100
#end
while !shell.isDisposed do
display.sleep unless display.readAndDispatch
end
display.dispose
@ashbb
Copy link
Author

ashbb commented Mar 10, 2012

The above snippet works. A red rectangle appears on a window. But after deleting number sign #s, I mean using Thread, nothing appear. Why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment