The spec explicitly says you cannot: stop, start, suspend or resume. It does *not* say you cannot sleep a Thread. If the spec authors didn't want you to sleep a thread they would have put it in the list, therefore you can. Simple.
Having said that. I find it hard to think of any reasons why you would want to. The original poster was talking about using it to emulate a long method call; well sleep wont emulate that very well since it will be idle. If you are trying to emulate a long method call, your delaying method should be active as well. Otherwise your profiling results will be [screwed | skewed] because other threads running will get more time. for(long end = System.currentTimeMillis() + DELAY; end > System.currentTimeMillis();) The only exception to this is if you are trying to emulate a remote call; in this case you should write a stub for your remote object and put the busy delay in there. This way you are still emulating the marshalling and network overhead involved. Rich On Thursday 25 April 2002 14:29 pm, you wrote: > Hi! > So, if my business logic requires a bean to sleep for a predefined > time-interval, what will be the most appropriate method to be used? > at the moment, i'm using Thread.sleep() as i could find no other way. and > it works alright. well, at least on the surface! > yogesh. > > "Thompson, Chris" wrote: > > I am wondering then what this part of the EJB 2.0 spec means from 24.1.2 > > Programming restrictions: > > > > "* The enterprise bean must not attempt to manage threads. The enterprise > > bean must not attempt to start, stop, suspend, or resume a thread; or to > > change a thread's priority or name. The enter-prise bean must not attempt > > to manage thread groups. > > These functions are reserved for the EJB Container. Allowing the > > enterprise bean to manage threads would decrease the Container's ability > > to properly manage the runtime environment." > > > > I would think that this means that a bean shouldn't manage its own thread > > or any other's. The only place I have heard (and recently from a BEA > > speaker) that you could "legally" create and/or manage threads, sockets, > > i/o, etc is in a JCA connector. I imagine the extreme of this would be > > if all active beans were sleeping for long periods of time, I don't know > > how well a container would handle this. Or what would happen if it > > wanted to passivate a sleeping bean. > > > > As discussed for testing purposes it would probably be ok to sleep with > > the appropriate InterruptedException catch, but with the knowledge that > > it may or may not have some affect upon the container's thread management > > if any. > > > > Chris Thompson > > Bean-test Developer > > http://www.empirix.com > > -- > "Bad times have a scientific value. These are the occasions a good learner > would not miss" > --Ralph Waldo Emerson > > > ********************************************************* > Disclaimer > > This message (including any attachments) contains > confidential information intended for a specific > individual and purpose, and is protected by law. > If you are not the intended recipient, you should > delete this message and are hereby notified that > any disclosure, copying, or distribution of this > message, or the taking of any action based on it, > is strictly prohibited. > > ********************************************************* > Visit us at http://www.mahindrabt.com > > =========================================================================== > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff EJB-INTEREST". For general help, send email to > [EMAIL PROTECTED] and include in the body of the message "help". ============================================================================== This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. All information is the view of the individual and not necessarily the company. If you are not the intended recipient you are hereby notified that any dissemination, distribution, or copying of this communication and its attachments is strictly prohibited. If you have received this email in error please notify: [EMAIL PROTECTED] ============================================================================== =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
