Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #4082 > unrolled thread

recreating timesharing IO

Started by"Tom A." <tom.a.@THRWHITE.remove-dii-this>
First post2011-04-27 15:48 +0000
Last post2011-04-27 15:48 +0000
Articles 7 — 4 participants

Back to article view | Back to comp.lang.java.gui


Contents

  recreating timesharing IO "Tom A." <tom.a.@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
    Re: recreating timesharin "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
    Re: recreating timesharin "Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
      Re: recreating timesharin "Tom A." <tom.a.@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
        Re: recreating timesharin "Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
    Re: recreating timesharin "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
      Re: recreating timesharin "Tom A." <tom.a.@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000

#4082 — recreating timesharing IO

From"Tom A." <tom.a.@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
Subjectrecreating timesharing IO
Message-ID<7df04a4a-bf7a-4615-9fb8-6a1664f231c5@d45g2000hsc.googlegroups.com>
  To: comp.lang.java.gui
I was looking through some old pascal line printer listings from
<mumble mumble> decades ago, and thought I'd try to recreate an old
game I wrote in Java.  Java, of course, doesn't do WRITELN and READLN
from the terminal, so I created a jframe with a  jscrollpane
containing a jtextarea for output, and below that a jtextfield to be
the input area.  The question is, how to make the program stop and
wait for input when it needs it.

I created a class called BasicIO that had a synchronized readln()
method that did a wait(), and an event listener that would do a
notify() when the event was from the input field, but it kept giving
me an
IllegalMonitorStateException.

Obviously, I'm quite confused by threads and monitors, and was hoping
someone could enlighten me?

Thanks.

Tom A.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#4083 — Re: recreating timesharin

From"Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: recreating timesharin
Message-ID<48b2c47e$1@news.uni-rostock.de>
In reply to#4082
  To: comp.lang.java.gui
Tom A. schrieb:
> I was looking through some old pascal line printer listings from
> <mumble mumble> decades ago, and thought I'd try to recreate an old
> game I wrote in Java.  Java, of course, doesn't do WRITELN and READLN
> from the terminal, so I created a jframe with a  jscrollpane

Of course java can. Try System.in and System.out.

> containing a jtextarea for output, and below that a jtextfield to be
> the input area.  The question is, how to make the program stop and
> wait for input when it needs it.
> 
Don't stop, just don't change the state you're in. Just fire an event after
the input ocurred and let the main program react on that event.

 >...
> Thanks.
> 
> Tom A.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#4084 — Re: recreating timesharin

From"Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: recreating timesharin
Message-ID<g8ugah$iqd$1@registered.motzarella.org>
In reply to#4082
  To: comp.lang.java.gui
On 25/08/2008 16:29, Tom A. allegedly wrote:
> I was looking through some old pascal line printer listings from
> <mumble mumble> decades ago, and thought I'd try to recreate an old
> game I wrote in Java.  Java, of course, doesn't do WRITELN and READLN
> from the terminal, 

Doesn't it?

<http://java.sun.com/docs/books/tutorial/essential/io/cl.html>

> so I created a jframe 

JFrame

> with a  jscrollpane

JScrollPane

> containing a jtextarea 

JTextArea

> for output, and below that a jtextfield 

JTextField

> to be
> the input area.  The question is, how to make the program stop and
> wait for input when it needs it.
> 
> I created a class called BasicIO that had a synchronized readln()
> method that did a wait(), and an event listener that would do a
> notify() when the event was from the input field, but it kept giving
> me an
> IllegalMonitorStateException.

Because you haven't acquired the Object's monitor.
<http://java.sun.com/javase/6/docs/api/java/lang/IllegalMonitorStateException.html>

> Obviously, I'm quite confused by threads and monitors, and was hoping
> someone could enlighten me?

<http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html>

And encompassing:
<http://java.sun.com/docs/books/tutorial/reallybigindex.html>

-- 
DF.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#4085 — Re: recreating timesharin

From"Tom A." <tom.a.@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: recreating timesharin
Message-ID<cb99769e-3d48-497d-9df5-031935f87ed0@c65g2000hsa.googlegroups.com>
In reply to#4084
  To: comp.lang.java.gui
On Aug 25, 9:41=A0am, Daniele Futtorovic <da.futt.n...@laposte.invalid>
wrote:
> On 25/08/2008 16:29, Tom A. allegedly wrote:
>
> > I was looking through some old pascal line printer listings from
> > <mumble mumble> decades ago, and thought I'd try to recreate an old
> > game I wrote in Java. =A0Java, of course, doesn't do WRITELN and READLN
> > from the terminal,
>
> Doesn't it?
>
> <http://java.sun.com/docs/books/tutorial/essential/io/cl.html>

OK, to rephrase, I knew about the pre-defined input and output stream
files, but didn't want to use them, as I was under the impression that
the program would have to be running in DOS mode to have access to
them.



> > I created a class called BasicIO that had a synchronized readln()
> > method that did a wait(), and an event listener that would do a
> > notify() when the event was from the input field, but it kept giving
> > me an
> > IllegalMonitorStateException.
>
> Because you haven't acquired the Object's monitor.
> <http://java.sun.com/javase/6/docs/api/java/lang/IllegalMonitorStateEx...=
>
>
> > Obviously, I'm quite confused by threads and monitors, and was hoping
> > someone could enlighten me?
>
> <http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html=
>
>
> And encompassing:
> <http://java.sun.com/docs/books/tutorial/reallybigindex.html>
>
> --
> DF.

Thank you for the help.  I'll check out those links.

Tom A.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#4087 — Re: recreating timesharin

From"Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: recreating timesharin
Message-ID<g8vf0c$9b1$1@registered.motzarella.org>
In reply to#4085
  To: comp.lang.java.gui
On 25/08/2008 18:57, Tom A. allegedly wrote:
> On Aug 25, 9:41 am, Daniele Futtorovic <da.futt.n...@laposte.invalid>
> wrote:
>> On 25/08/2008 16:29, Tom A. allegedly wrote:
>>
>>> I was looking through some old pascal line printer listings from
>>> <mumble mumble> decades ago, and thought I'd try to recreate an old
>>> game I wrote in Java.  Java, of course, doesn't do WRITELN and READLN
>>> from the terminal,
>> Doesn't it?
>>
>> <http://java.sun.com/docs/books/tutorial/essential/io/cl.html>
> 
> OK, to rephrase, I knew about the pre-defined input and output stream
> *files*, but didn't want to use them, as I was under the impression that
> the program would have to be running in *DOS* mode to have access to
> them.

"Files"?! "DOS"?! Say, you're a Windoze user, aren't you?

Just kidding. But you're mistaken. However, it may be that due to some
specific circumstances you might have to go the way you planned to
anyway, so go ahead.

-- 
DF.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#4091 — Re: recreating timesharin

From"Roedy Green" <roedy.green@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: recreating timesharin
Message-ID<0127b41tv6toplpeep5t82pkqvl5l6q4lm@4ax.com>
In reply to#4082
  To: comp.lang.java.gui
On Mon, 25 Aug 2008 07:29:07 -0700 (PDT), "Tom A."
<meteoricshipyards@yahoo.com> wrote, quoted or indirectly quoted
someone who said :

>I created a class called BasicIO that had a synchronized readln()
>method that did a wait(), and an event listener that would do a
>notify() when the event was from the input field, but it kept giving
>me an
>IllegalMonitorStateException.

Events are nice discrete short things. You don't need wait etc to deal
with them. See http://mindprod.com/jgloss/event11.html
to understand how they work.
-- 

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#4097 — Re: recreating timesharin

From"Tom A." <tom.a.@THRWHITE.remove-dii-this>
Date2011-04-27 15:48 +0000
SubjectRe: recreating timesharin
Message-ID<c4bde30a-9e59-4aaf-a79d-efb928bba473@n38g2000prl.googlegroups.com>
In reply to#4091
  To: comp.lang.java.gui
On Aug 25, 11:36=A0pm, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
> On Mon, 25 Aug 2008 07:29:07 -0700 (PDT), "Tom A."
> <meteoricshipya...@yahoo.com> wrote, quoted or indirectly quoted
> someone who said :
>
> >I created a class called BasicIO that had a synchronized readln()
> >method that did a wait(), and an event listener that would do a
> >notify() when the event was from the input field, but it kept giving
> >me an
> >IllegalMonitorStateException.
>
> Events are nice discrete short things. You don't need wait etc to deal
> with them. See http://mindprod.com/jgloss/event11.html
> to understand how they work.
> --
>
> Roedy Green Canadian Mind Products
> The Java Glossaryhttp://mindprod.com

Thank you for the link.  That document explained what was going on (I
think ....)
The event handling was being invoked in the EventDispatchedThread, so
it didn't have the monitor for the main program when it issued the
notify().

This seems a bit complicated to this Object Oriented programmer who
was trained when Ada was the coming thing :-)

Tom A.
Who hasn't programmed anything substantial in probably 20 years.
Damn, I feel old.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web