mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-19 06:58:54 +08:00
18e1f2bd67
* HACKING, gnu/gcj/xlib/Pixmap.java, gnu/gcj/xlib/XException.java, gnu/java/rmi/rmic/RMIC.java, java/awt/Window.java, java/awt/AWTEvent.java, java/io/ByteArrayOutputStream.java, java/io/CharConversionException.java, java/io/PipedInputStream.java, java/io/PipedReader.java, java/io/PrintWriter.java, java/io/WriteAbortedException.java, java/io/natFileWin32.cc, java/lang/Class.h, java/lang/natClassLoader.cc, java/lang/natObject.cc, java/lang/Package.java, java/net/BindException.java, java/net/ConnectException.java, java/net/ProtocolException.java, java/net/SocketException.java, java/net/UnknownServiceException.java, java/security/cert/X509Certificate.java, java/security/interfaces/DSAKey.java, java/security/SecureRandom.java, java/security/SignedObject.java, java/sql/DatabaseMetaData.java, java/text/DecimalFormatSymbols.java, java/util/jar/Attributes.java, java/util/jar/JarEntry.java, java/util/jar/JarInputStream.java, java/util/jar/JarOutputStream.java, java/util/Calendar.java, java/util/Collections.java, java/util/GregorianCalendar.java, java/util/HashMap.java, java/util/List.java, java/util/Properties.java, java/util/Timer.java, java/util/Vector.java, java/util/WeakHashMap.java, javax/naming/NamingException.java, testsuite/libjava.lang/Thread_Wait.java, org/xml/sax/helpers/DefaultHandler.java, org/xml/sax/HandlerBase.java, org/xml/sax/SAXParseException.java, ChangeLog, acinclude.m4, aclocal.m4, posix-threads.cc: Fix spelling errors. * configure: Regenerate. From-SVN: r46665
50 lines
903 B
Java
50 lines
903 B
Java
// Test basic thread creation and wait/notify functionality.
|
|
// Origin: Bryce McKinlay <bryce@albatross.co.nz>
|
|
|
|
public class Thread_Wait implements Runnable
|
|
{
|
|
public static void main(String args[])
|
|
{
|
|
new Thread_Wait();
|
|
}
|
|
|
|
public Thread_Wait()
|
|
{
|
|
System.out.println("creating thread");
|
|
Thread t = new Thread(this);
|
|
t.start();
|
|
|
|
try
|
|
{
|
|
Thread.sleep(100);
|
|
}
|
|
catch (Exception x)
|
|
{
|
|
System.out.println("exception occurred: " + x);
|
|
}
|
|
|
|
synchronized (this)
|
|
{
|
|
System.out.println("notifying other thread");
|
|
notify();
|
|
}
|
|
}
|
|
|
|
public void run()
|
|
{
|
|
System.out.println ("new thread running");
|
|
synchronized (this)
|
|
{
|
|
try
|
|
{
|
|
wait();
|
|
}
|
|
catch (Exception x)
|
|
{
|
|
System.out.println("exception occurred: " + x);
|
|
}
|
|
}
|
|
System.out.println ("thread notified okay");
|
|
}
|
|
}
|