1/19
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Thread
This is a flow of execution, it has light weight processes and exists within a process. It shares resources like memory and open files
Ways you can create a thread of execution
Write a class to extend the thread class
Write a class that implements a runnable interface and tap it in a thread
Processes
A self contained execution environment, has its own memory and resources
What’s the difference between start and run
start allows threads to run concurrently while the run methods directly runs the threads syncronously
Join()
When a thread joins another , it is blocked until the the thread being joined on finishes. This technique is used when your thread depends on another thread
Wait()
causes the current thread to wait until another thread invokes the notify() method or notifyall()
Notify()
Wakes up a single thread that is waiting on this objects monitor.
Notifyall()
Wakes up all the threads are waiting on this objects
Java Thresd life cycle
The thread constructor is called a new instance of the thread class
The start merges is called to designate rhe thread as runnable
The Java thread scheduler runs rhe thread as the processor becomes available
The thread can be blocked for various reasons and will not run again until it is returned to the Runnable State
If fhe thread calls the wait method, it is put into the waiting state and will remain their until another thread calls the notify or notify all method
The thread ends when the run method terminates
Deadlock
This is a scenario where two or more threads are blocked indefinitely waiting for access to a critical resource.
Socket
One endpoint of a two-way communication link between two programs running on the network
Accept()
Calling accept on the server blocks the server until a client connects to the port
What Happens when a client connects to a server
It unblocks and gets back a client socket
Dr Ça