GIDForums  

Go Back   GIDForums > Computer Programming Forums > Java Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #21  
Old 29-Sep-2009, 12:24
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: How to continue program operation while animation loop is running


Quote:
Originally Posted by ebot9000
In a more complicated program is it better to have classes manage their own threads like that, or is it better to have them all in the main class?
I'm not 100% sure which is "better", for it seems the opinions vary greatly, and the short answer is usually, "...it depends on the particular application." [any others on the forum have input for this??]

Since I've been out of college for 10yrs. now, what is the latest idea(s) from the professor? (propose the difference, and get their viewpoint/suggestion) I'd be curious to know the result.

EDIT:
It seems that interrupt() has many side affects [i.e. might require extra exception handling -- see the Java API], where I merely set a flag to allow the thread to exit in a more clean [I think] fashion.
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #22  
Old 29-Sep-2009, 12:46
ebot9000 ebot9000 is offline
New Member
 
Join Date: Jul 2009
Posts: 20
ebot9000 is on a distinguished road

Re: How to continue program operation while animation loop is running


Unfortunately it's an online video course that Stanford posts for free on youtube, so there's no opportunity to ask the professor.

He introduced threading it in its most basic form, with the Thread object appearing in the main class. It's not a detailed enough explanation to know whether your approach might be better in some cases.

Yeah, other input would be enlightening.
  #23  
Old 29-Sep-2009, 12:49
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: How to continue program operation while animation loop is running


Quote:
Originally Posted by JavaAPI_about_stop()
Deprecated. This method is inherently unsafe. Stopping a thread with Thread.stop causes it to unlock all of the monitors that it has locked (as a natural consequence of the unchecked ThreadDeath exception propagating up the stack). If any of the objects previously protected by these monitors were in an inconsistent state, the damaged objects become visible to other threads, potentially resulting in arbitrary behavior. Many uses of stop should be replaced by code that simply modifies some variable to indicate that the target thread should stop running. The target thread should check this variable regularly, and return from its run method in an orderly fashion if the variable indicates that it is to stop running. If the target thread waits for long periods (on a condition variable, for example), the interrupt method should be used to interrupt the wait.
Here's another reason for "it depends", I went with what they say in the red text. However, they do mention interrupt() in the blue text. So, it's back to the "...depends on the application..." thing.

What makes it annoying is the portion "...waits for long periods...", concerning the interrupt. Well, that time period is vague [aka: undefined] to me. How to define a "long period" varies greatly by opinion!!

EDIT:
...This still doesn't answer the original question concerning classes with their own threads, or all threads from main, though. [Maybe Java alludes to this somewhere in the information link that I had in my first post? I'll have to check this too.]
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Equation solver RazoR C Programming Language 3 18-May-2008 10:24
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 08:44
Two-Tier data dissemination code installation problem nidhibansal1984 Computer Software Forum - Linux 6 16-Sep-2007 11:13
Text-Based Roulette Game mfm1983 C++ Forum 5 29-Nov-2006 13:20

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 06:57.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.