Maggieshah
asked on
Thread, synchronized, wait(), notify, notifyall
could u plz explain what these concept means in a very short way....and give some example where it is possible to use...
why we have threads in programming????
what mean thread??
what mean synchronizd??
what mean locks, notify and notifyall..
why we have threads in programming????
what mean thread??
what mean synchronizd??
what mean locks, notify and notifyall..
> why we have threads in programming????
When you want/need to do more than one thing at the same time
> what mean thread??
a thread is single thread of execution
> what mean synchronizd??
means a block of code that is guaranteed to only be executed by a single thread at one time
other threads will wait until it is com[plete before executing
> what mean locks, notify and notifyall..
they are for controlling thread execution
when a thread can hold a lock on a object, and also notify other threads when locks are freed etc.
ASKER
what mean deadlock??
when thread A is waiting for a lock help be thread B
But thread B is also waiting on a lock held by thread A
so both qare stuck
http://mindprod.com/jgloss/deadlock.html
But thread B is also waiting on a lock held by thread A
so both qare stuck
http://mindprod.com/jgloss/deadlock.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The below 2 links will answer most of your questions
http://www.bpurcell.org/blog/index.cfm?mode=entry&ENTRY=934
http://www-128.ibm.com/developerworks/java/library/j-thread.html
The below links will also help
http://www.isr.umd.edu/~austin/ence489c.d/threads.html
http://www.cs.clemson.edu/~cs428/resources/java/tutorial/JTThreadEx.html
http://www.javaworld.com/javaworld/jw-04-1996/jw-04-threads.html
http://www.bpurcell.org/blog/index.cfm?mode=entry&ENTRY=934
http://www-128.ibm.com/developerworks/java/library/j-thread.html
The below links will also help
http://www.isr.umd.edu/~austin/ence489c.d/threads.html
http://www.cs.clemson.edu/~cs428/resources/java/tutorial/JTThreadEx.html
http://www.javaworld.com/javaworld/jw-04-1996/jw-04-threads.html
> and give some example where it is possible to use
consider you are writing a client/server chat system. the server must be able to deal with more than one client at a time. The way of dealing with this in Java is by multithreading. a thread is a task, or process, that may run in parallel with other processes. simply a thread is a program's path of execution. Multithreaded applications deliver their potent power by running many threads concurrently within a single program. From a logical point of view, multithreading means multiple lines of a single program can be executed at the same time. so in my example, the multithreaded chat server waits for a connection, when a connection is made, a new thread will be created and then looks after that connection. The server then waits for another connection while the client threads are listening to each client's request concurrently.
consider you are writing a client/server chat system. the server must be able to deal with more than one client at a time. The way of dealing with this in Java is by multithreading. a thread is a task, or process, that may run in parallel with other processes. simply a thread is a program's path of execution. Multithreaded applications deliver their potent power by running many threads concurrently within a single program. From a logical point of view, multithreading means multiple lines of a single program can be executed at the same time. so in my example, the multithreaded chat server waits for a connection, when a connection is made, a new thread will be created and then looks after that connection. The server then waits for another connection while the client threads are listening to each client's request concurrently.
>> why we have threads in programming????
Consider a case of a simple web-server like Yahoo or experts-exchange. There is a web-application running there which 100s of users are accessing. So the web-server process needs to handle all of these requests 'parallelly', hence in different threads simultaneously so that it doesn't make one user wait until it has entirely handled the other user.
Consider a case of a simple web-server like Yahoo or experts-exchange. There is a web-application running there which 100s of users are accessing. So the web-server process needs to handle all of these requests 'parallelly', hence in different threads simultaneously so that it doesn't make one user wait until it has entirely handled the other user.
http://java.sun.com/docs/books/tutorial/essential/threads/