![Rishi Yadav](/img/default-banner.jpg)
- 88
- 2 442 001
Rishi Yadav
India
Приєднався 22 кві 2010
Lecturer at MP Technical Education
java 43 | Thread class methods | Thread class constructors | sleep(), join () | setName (), setId()
Thread class provide constructors and methods to create and perform operations on a thread.
Thread class extends Object class and implements Runnable interface.
At the end of this class students will be able to understand:-
Thread class constructors
Thread class methods
Following is the declaration for java.lang.Thread class −
public class Thread extends Object implements Runnable
{
….
….
}
Thread class extends Object class and implements Runnable interface
constructors
Thread()
Thread(String name)
Thread(Runnable r)
Thread(Runnable r,String name)
Methods
currentThread( ): java.lang.Thread.currentThread() Returns a reference to the currently executing thread object
Syntax:
public static Thread currentThread()
Returns: the currently executing thread
run(): java.lang.Thread.run()
Syntax:
public void run()
Description: If this thread was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns. Subclasses of Thread should override this method.
start(): java.lang.Thread.start() Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread
Syntax:
public void start()
Throws:
IllegalThreadStateException - if the thread was already started.
getName(): java.lang.Thread.getName() Returns this thread’s name
Syntax:
public final String getName()
Returns: this thread's name
getId(): java.lang.Thread.getId() Returns the identifier of this Thread
Syntax:
public long getId()
Returns: this thread's ID
setName(String name): java.lang.Thread.setName(String name) Changes the name of this thread to be equal to the argument name.
Syntax:
public final void setName(String name)
Parameters: name - the new name for this thread.
Throws: SecurityException - if the current thread cannot modify this thread.
isAlive(): java.lang.Thread.isAlive() Tests if this thread is alive
Syntax:
public final boolean isAlive()
Returns: true if this thread is alive; false otherwise
getPriority(): java.lang.Thread.getPriority() Returns this thread’s priority
Syntax:
public final int getPriority()
Returns: this thread's priority
setPriority(int newPriority): java.lang.Thread.setPriority(int newPriority)
Changes the priority of this thread
Syntax:
public final void setPriority(int newPriority)
Parameters: newPriority - priority to set this thread to Throws:
IllegalArgumentException- If the priority is not in the range MIN_PRIORITY to MAX_PRIORITY
SecurityException - if the current thread cannot modify this thread.
join(): java.lang.Thread.join() Waits for this thread to die
Syntax:
public final void join() throws InterruptedException
Throws:
InterruptedException - if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown
join(long millis): java.lang.Thread.join(long millis) Waits at most millis milliseconds for this thread to die
Syntax:
public final void join(long millis) throws InterruptedException
Parameters: millis - the time to wait in milliseconds
Throws:
IllegalArgumentException - if the value of millis is negative InterruptedException - if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
sleep(long millis): java.lang.Thread.sleep(long millis) Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds, subject to the precision and accuracy of system timers and schedulers
Syntax:
public static void sleep(long millis) throws InterruptedException Parameters: millis - the length of time to sleep in milliseconds Throws: IllegalArgumentException - if the value of millis is negative
InterruptedException - if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
summary
Thread class provides constructors and methods to create and perform operations on a thread to:-
Create and Run the thread
Set the name and id of thread
Get the name and id of the thread
Set the priority of the thread
To put itself to sleep and join after other thread is dead
list of suggested reading
Java: The Complete Reference Book by Herbert Schildt
ua-cam.com/play/PLA3taA2THXpy0q0TxYd4i5dpk76HpsZ_n.html
www.geeksforgeeks.org/java-lang-thread-class-java/
Thread class extends Object class and implements Runnable interface.
At the end of this class students will be able to understand:-
Thread class constructors
Thread class methods
Following is the declaration for java.lang.Thread class −
public class Thread extends Object implements Runnable
{
….
….
}
Thread class extends Object class and implements Runnable interface
constructors
Thread()
Thread(String name)
Thread(Runnable r)
Thread(Runnable r,String name)
Methods
currentThread( ): java.lang.Thread.currentThread() Returns a reference to the currently executing thread object
Syntax:
public static Thread currentThread()
Returns: the currently executing thread
run(): java.lang.Thread.run()
Syntax:
public void run()
Description: If this thread was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns. Subclasses of Thread should override this method.
start(): java.lang.Thread.start() Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread
Syntax:
public void start()
Throws:
IllegalThreadStateException - if the thread was already started.
getName(): java.lang.Thread.getName() Returns this thread’s name
Syntax:
public final String getName()
Returns: this thread's name
getId(): java.lang.Thread.getId() Returns the identifier of this Thread
Syntax:
public long getId()
Returns: this thread's ID
setName(String name): java.lang.Thread.setName(String name) Changes the name of this thread to be equal to the argument name.
Syntax:
public final void setName(String name)
Parameters: name - the new name for this thread.
Throws: SecurityException - if the current thread cannot modify this thread.
isAlive(): java.lang.Thread.isAlive() Tests if this thread is alive
Syntax:
public final boolean isAlive()
Returns: true if this thread is alive; false otherwise
getPriority(): java.lang.Thread.getPriority() Returns this thread’s priority
Syntax:
public final int getPriority()
Returns: this thread's priority
setPriority(int newPriority): java.lang.Thread.setPriority(int newPriority)
Changes the priority of this thread
Syntax:
public final void setPriority(int newPriority)
Parameters: newPriority - priority to set this thread to Throws:
IllegalArgumentException- If the priority is not in the range MIN_PRIORITY to MAX_PRIORITY
SecurityException - if the current thread cannot modify this thread.
join(): java.lang.Thread.join() Waits for this thread to die
Syntax:
public final void join() throws InterruptedException
Throws:
InterruptedException - if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown
join(long millis): java.lang.Thread.join(long millis) Waits at most millis milliseconds for this thread to die
Syntax:
public final void join(long millis) throws InterruptedException
Parameters: millis - the time to wait in milliseconds
Throws:
IllegalArgumentException - if the value of millis is negative InterruptedException - if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
sleep(long millis): java.lang.Thread.sleep(long millis) Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds, subject to the precision and accuracy of system timers and schedulers
Syntax:
public static void sleep(long millis) throws InterruptedException Parameters: millis - the length of time to sleep in milliseconds Throws: IllegalArgumentException - if the value of millis is negative
InterruptedException - if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
summary
Thread class provides constructors and methods to create and perform operations on a thread to:-
Create and Run the thread
Set the name and id of thread
Get the name and id of the thread
Set the priority of the thread
To put itself to sleep and join after other thread is dead
list of suggested reading
Java: The Complete Reference Book by Herbert Schildt
ua-cam.com/play/PLA3taA2THXpy0q0TxYd4i5dpk76HpsZ_n.html
www.geeksforgeeks.org/java-lang-thread-class-java/
Переглядів: 733
Відео
java 42 | Thread Life Cycle | states of a thread
Переглядів 3044 роки тому
objective At the end of this class students will: - Understand the life cycle of a thread Understand thread states. introduction When there are many threads (multithreading) the JVM decides which thread will first gets executed and how long. So it is the responsibility of JVM scheduler to choose which one to run. You can add some code to set the thread priority. You can add some code to wait fo...
java 41 | Threads in java | How to create Threads in java | Runnable interface | Extend Thread class
Переглядів 2074 роки тому
A thread is a lightweight sub-process, the smallest unit of processing. At the end of this class students will be able to : - Understand what is Thread. Create threads. Extend the Thread class. Implement the Runnable interface. Thread It is a separate path of execution. Threads are independent. If there occurs exception in one thread, it doesn't affect other threads. It uses a shared memory are...
java 40 | wrapper class in java | autoboxing unboxing in java | parseDouble () method in java
Переглядів 1814 роки тому
The wrapper class in Java provides the mechanism to convert primitive into object and object into primitive. At the end of this class students will be able to : - Use Integer class Convert objects into primitive types. Convert primitive types into object. Understand Autoboxing and Unboxing Everything in java is object except the primitive type. The classes which are used to convert the primitiv...
java 39 | StringBuffer and StringBuilder class | mutable string
Переглядів 954 роки тому
Java StringBuffer class is used to create mutable (modifiable) string. The StringBuffer class in java is same as String class except it is mutable i.e. it can be changed. At the end of this class students will be able to : - Use StringBuffer class Use StringBuilder class Apply reverse( ) method to reverse the strings. StringBuffer and StringBuilder classes are used for creating mutable string. ...
java 38 | String class methods | compareTo() method | toLowerCase() | string concat using +
Переглядів 794 роки тому
String class has various methods, I am going to cover few of them. At the end of this class students will be able to : - Apply charAt ( ) method to find a character at particular place Apply replace( ) method to replace one char with other Apply compareTo( ) method to compare two strings. Apply concat( ) method for concatenation of strings. There are various methods available in string class co...
java 37 | Strings in java | Why Strings are immutable in java | How to create Strings in java
Переглядів 694 роки тому
At the end of this class students will be able to understand What is string in java How string can be created? Why strings are immutable? String is a sequence of characters In Java, string is basically an object that represents sequence of char values. An array of characters works same as Java string. How to create String object There are two ways to create String object: By string literal By n...
java 36 | Arrays as objects in java | Array of References of any object
Переглядів 724 роки тому
Array is a collection of objects of same type. In java when you create an array that array is an object. “ Arrays are objects in java that store multiple object references or primitives of same data type” int [] scores; Declaration of an array variable does not allocate any space in memory for array, only a storage location for the reference to an array is created. Scores = new int [5]; Array m...
java 35 | Two Dimensional Array
Переглядів 724 роки тому
Multidimensional Arrays can be defined in simple words as array of arrays. Two - dimensional array is the simplest form of a multidimensional array. Two - dimensional array is the simplest form of a multidimensional array. A two - dimensional array can be seen as an array of one - dimensional arrays for easier understanding. Declaration data_type[][] array_name = new data_type[x][y]; For exampl...
java 34 | Arrays in java | How to declare array in java | Initialization and accessing of elements
Переглядів 964 роки тому
Arrays are collection of items or elements of similar types. Arrays are objects in java that store multiple object references or primitives of same type. data_types [] arrayRef; Declaring an array of primitive int values []; int [] values; Declaring an array of object references : Student s[]; Student [] s; Declaring multidimensional array : int TwoD [][] t; int TwoD [] t []; Declaration of an ...
java 33 | Creating package in java | How to add a class in java package
Переглядів 1,2 тис.4 роки тому
In last lecture we have seen packages. A package in Java is used to group related classes. Think of it as a folder in a file directory. Packages are divided into two categories: Built-in Packages (packages from the Java API) User-defined Packages (create your own packages) To use a class or a package from the library, you need to use the import keyword: In this lecture we are going to create an...
java 32 | Packages in java | In built packages | How to use packages in java
Переглядів 2134 роки тому
Package in Java is a mechanism to encapsulate a group of classes, sub packages and interfaces. Packages are used in Java in order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations easier, etc. Using packages, it is easier to provide access control and it is also easier to locate the related classes A Package...
java 31 | Extending Interfaces | Accessing interface fields
Переглядів 1804 роки тому
In this class we are going to talk about inheriting interfaces and accessing inheritance fields. A class can inherit multiple interfaces but not multiple classes An interface can also inherit multiple interfaces Multiple inheritance is not supported through class in java, but it is possible by an interface, why? multiple inheritance is not supported in the case of class because of ambiguity. Ho...
java 30 | interface in java | total abstraction in java
Переглядів 884 роки тому
In this class we are going to talk about interface in java interface is used to achieve total abstraction interface is a blueprint of a class it specifies a set of methods that the class has to implement If a class implements an interface and does not provide method bodies for all functions specified in the interface, then the class must be declared abstract. As you already know that abstractio...
java 29 | final keyword | final variable | final method | final class | finala=ize method
Переглядів 534 роки тому
The final keyword in java is used to restrict the user. The java final keyword can be used in many context. Final can be: variable method class The final keyword can be applied with the variables, a final variable that has no value it is called blank final variable or uninitialized final variable. It can be initialized in the constructor only. The blank final variable can be static also which w...
Java 28 | Abstract class Program | Abstract method in Java
Переглядів 434 роки тому
Java 28 | Abstract class Program | Abstract method in Java
JAVA 27 | Abstraction in java | Abstract class in java
Переглядів 294 роки тому
JAVA 27 | Abstraction in java | Abstract class in java
Java 26 | Runtime polymorphism | Rules for Method Overriding
Переглядів 574 роки тому
Java 26 | Runtime polymorphism | Rules for Method Overriding
Java 24 | super keyword in java | invoking super class constructor
Переглядів 954 роки тому
Java 24 | super keyword in java | invoking super class constructor
Java 22 | Access Modifiers | Public | Protected | Private | Default
Переглядів 564 роки тому
Java 22 | Access Modifiers | Public | Protected | Private | Default
Java 21 | Inheritance in Java | Encapsulation and Abstraction
Переглядів 284 роки тому
Java 21 | Inheritance in Java | Encapsulation and Abstraction
Java 20 | Types of constructors | Default constructor | No arg Constructor | Parameterized Construtr
Переглядів 654 роки тому
Java 20 | Types of constructors | Default constructor | No arg Constructor | Parameterized Construtr
Java 18 | Accessing Instance Variables and Methods
Переглядів 1504 роки тому
Java 18 | Accessing Instance Variables and Methods
Java 17 | Class and Objects in Java | Constructor | Creating objects in java
Переглядів 304 роки тому
Java 17 | Class and Objects in Java | Constructor | Creating objects in java
Java - 16 | Loops in java | While | Do- while | For loop
Переглядів 294 роки тому
Java - 16 | Loops in java | While | Do- while | For loop
Java 15 | Control statement | if - else | switch - case
Переглядів 304 роки тому
Java 15 | Control statement | if - else | switch - case
Java 14 |Operators in Java | Arithmetic | Relational | Logical | Bitwise | Assignment Operators
Переглядів 344 роки тому
Java 14 |Operators in Java | Arithmetic | Relational | Logical | Bitwise | Assignment Operators
पानी का निसान गलत जगह लगाया है साफ दिख रहा है गोर से देखो पता चल जाता
औऔ
7 years ago a legend teacher started his UA-cam journey 🔥🔥 We want comeback ♥️
5:16 par isne rise ki air loose ki h qki. Isko pata h isne jyda air nikal di😂😂😂😂... Chutiya banane walo ki kami nhi h
Ye b fake h lote ko pahle ache se thok k le jao fir uth jayega ....baar baar tar upper niche karne se chawal k bich ka air gape kam ho jata or last me aisa aata hi air gape bilkul b nhi rahta to lota uth jata h😂😂😂😂
Any one can do this method
Lota mahal ke
क्या सभी के साथ होगा सरजी या इसका मंत्र है बताएंगे
Kon Sha gaw he bhay apka mobile nambar dena bhay
मेरा अनुभव है. कोई विधी के बीणाही एक सच्चा ईन्सांन आगर जीभ क्षेत्र मे पाणी ओर बोर मारे तो पाणी लग शकता है. मैने खेत ओर घर मे ईश्वर का नाम लेकर बोर मारे है. दोन्ही जगणे मुझे 40 फुट ओर घर मे 100 फुट पे भरपुर पाणी लगा है. जो मेरे खेत मे 40 साल ओर घर मे 16 साल से चल रहा है.
लोहे की कील को ताम्बे की लोटे पर तेजी से टकराये इससे चिपक जाता है
Konsa chabal
Abe us lote me chhota sa chhed hai dhiyan se dekho usi me ye suja fasa leta hai dhongi sala
Yadavji ap konse state se
Nice explanation ❤
Trick batana chahiye tha copper hi kyon,suwa hi kyon aakhir Yadav name k beykti me hi kyon?
अंधभक्त ही सच मान सकता है
भाई साहब, यह अवैज्ञानिक पद्धति - नारियल, मेटल के सड(Rodes), , अंग्रेजी Y आकारकी पेड की हरी पतली डाल, pendulum, इत्यादि का प्रयोग भूजल संशोधन के लिए नुकसानदायक होता है। वनस्पतिविज्ञान से कहां पानी है या नहीं है दरअसल देखने की पद्धति अब कालबाह्य हो गये है, क्यों कि भुगर्भमेंसे बहुत सारे पानी खींच लिया है, और भूस्तर में बहुत कम जगह पानी बचा हुआ है। अगर बोरवेल(नलकूप) और कुएं का निर्माण करने के लिए असली आधुनिक विज्ञान और तकनीक का प्रयोग किया जाता है तो वहीं पर बोरवेल और कुएं कहां पर बनाने उन जगहों को निश्चित करने के लिए कयो उपयुक्त असली आधुनिक विज्ञान और तकनीक का प्रयोग नहीं किया जाता है? हकीकत में भूगर्भ जल अनुसंधान के लिए बनावटी जर्मन और जापानी टेक्नोलॉजी की मशीन: ADMT, PQWT, PULL FINDER, जैसे मशीनों का प्रयोग नहीं करने चाहिए, बल्कि शासन प्रमाणित और युनिवर्सिटी प्रमाणित रेजिस्टीवीटी मशीनों का प्रयोग ही उचित और अधिक अपेक्षाकृत परिणाम दे सकते हैं। ज्यादा जानकारी के लिए संपर्क करें: ९८२२६४५७८७ डॉ. सुरेश पवार, पुणे, महाराष्ट्र और ९९७८११५९६८ रतिलाल सुदाणी, आणंद, गुजरात
अंधविश्वास है
The best teacher everrrr..!!!!!!
For broadcast terget hardware address field will be FF:FF:FF:FF:FF:FF
Sir this much deep is very necessary for those who want to get into security field.
Sir your videos are really helpful for concept clearing Great work sir❤
Kon sa chawal
ये सभी से हो सकता है बॉस
Nice video sir very informative ❤
not that good.. below avg
competition hai pahle kyon nahin hua pahle bhi to round mara tha
ये तो घर पर केर्लो लोटा उठ जावेगी।
गड़बड़ झाला लगता है
Bhai mujhe bhi tubel lagvana he mujhe no. Do
Sir, TCP is not connection oriented protocol. It is a reliable protocol. TCP model doesn't have any protocol for being connection oriented unlike in OSI model we had X.25, SNPA
TEACHES GOOD
Sir blood group o positive hona chahiya
जिन को नंबर chaye mujhe मेसज करे
Bhai mere pass 27 acer jamin m lekin ek liter pani nhi h bhai bahut pareshan hu 10 saalo se aap paise le lo bhai lekin us admi la mobile no de do hum ko v check karbana na h pani .. bhai m hi aap k ghr lene aayuga or chodne v jayuga jitna uchit paise lege to m paise dene k liye v tayiyar hu 🙏🙏🙏🙏🙏🙏🙏🙏 kryiya kare k no.. send k dijiye m v Madhya Pradesh ka hu raisen district se 🙏🙏🙏
Sabha Zut he pagal lok he aap
Re साल लोटा में छेद है... सबों को चुटिया बना रहा हैं... आप लोग जरा देखे की चावल पलटते समय छेद दिखाई देता हैं
This is fact..even,stick and coconut is used to confirm the ground water for digging well/borewell
ये सब गलत है आप घर में कहीं भी बैठकर ये प्रयोग करेंगे तो ये होता है,चावल पालिस वाले न हो वो पूराने हो तो चावल मे कोई बार अंदर बाहर करने पर हवा बाहर होकर राड को पकड़ लेता है ये पहले भी देख चुका हूँ महाराष्ट्र के अंधश्रद्धा उनमूलन समिति से ज्ञान मानव जी के लोग बडी आसानी से कर दिखाते हैं और कारण भी बताते हैं।
फोन नंबर भेजें
बिना पालिश का चावल होगा तो ये कोई भी कर सकता है
Barbara send Karo
अगर वास्तव मे उस जगह पर पानी है तो बतायी गई विधी किसी से भी कराये सफल होनी चाहिए क्या आदमी चेज होने से पानी नही मिलेगा ऐ उचित नही लगता ।
Bhai sahab tapper mil sakte hain kya inke
Mere yaha pe bata do ful pani bhai pese bhi duga
Bevkuf banana hai
Thank you so much 🥰
गलत विधि है वार वार चावल में सूजा चुभाने से चावल टाईट हो जाता होगा इस लिए सूजा फस जावेगा
sir how to say thank 😊 *****