aspose file tools*
The moose likes Object Relational Mapping and the fly likes what is meant by single threaded Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "what is meant by single threaded" Watch "what is meant by single threaded" New topic
Author

what is meant by single threaded

sudheer kiran
Ranch Hand

Joined: Jun 26, 2008
Posts: 237

i read session is single threade what is meant by single threaded.


Sudheer
SCWCD, SCJP 5
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

It means a program runs in one thread.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
sudheer kiran
Ranch Hand

Joined: Jun 26, 2008
Posts: 237

so a partcular session cant be spawned to another thread.
a session object created in a thread will end in the same thread.
is that correct.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42632
    
  65
so a partcular session cant be spawned to another thread.

I'm not sure what you been by "spawned" in this context. Any object can be passed to any thread. Whether the object still works correctly if it is used in another thread is a different question, though. The javadocs should cover that. A still different question is whether an object can be used in several threads simultaneously; this, too, should be covered in the javadocs.

a session object created in a thread will end in the same thread. is that correct.

No; see above. It's trivial to pass an object from one thread into another thread.


Ping & DNS - my free Android networking tools app
sudheer kiran
Ranch Hand

Joined: Jun 26, 2008
Posts: 237

can you please explain me in case of org.hibernate.Session
they say Session is single threaded.
and single threaded " it means a program runs in one thread."
i am not able to understand why session is single threaded.
is session exists in the present thread only?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42632
    
  65
An object is not single-threaded; an application is (or is not).

So you're talking about org.hibernate.Session. What those javadocs actually say is that it is not safe to use a Session object in more than one thread. If your code has multiple threads, then each thread needs to obtain its own Session object.

Objects are often not made thread-safe because of performance reasons, or because through the way they're used non-thread-safety is not perceived as a problem.
sudheer kiran
Ranch Hand

Joined: Jun 26, 2008
Posts: 237

hmm i got it
very thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is meant by single threaded