CrazyEngineers
  • problem based on java programming language

    sherya mathur

    sherya mathur

    @sherya-mathur-cI63wY
    Updated: Oct 22, 2024
    Views: 1.0K
    Q:What is multithreading in java programming language and what are the methods
    for inter-thread communication and what is the class in which these methods
    are defined?
    😁
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Manish Goyal

    MemberApr 26, 2010

    Muti-threading means to divide a particular tasks into many tasks .It is one of the features of java .

    The methods for multi-threading are available in thread class or you can also implement a interface named Runnable which provides you methods like run(),init() using that you can create threads according to requirements for your application.
    Are you sure? This action cannot be undone.
    Cancel
  • kaniyarasu

    MemberApr 26, 2010

    In Java, we can use two way to implement multithreading concept
    -->By extending class Thread to our class
    -->By implementing Runnable interface to our class

    In both method we needs implement functionality of thread in default method called run()

    Its signature is: void run(){//here write implementation}

    And to invoke run() method call start() method as follows:
    start();

    It automatically invokes run method...

    For some tips just visit: <a href="https://fruitspot.wordpress.com" target="_blank" rel="nofollow noopener noreferrer">All about fruits</a>
    Are you sure? This action cannot be undone.
    Cancel
  • sushant005

    MemberApr 26, 2010

    @Shreya Mathur
    Q1:What is multithreading in java programming language?
    Ans> A thread is defined as the path of execution of a program.It is a sequence of instructions that is executed to define a unique flow of control.
    A process that creates two or more threads is called a multithreaded process.
    for example:-
    An browser like Internet Explorer is multithreaded process,within which you can play video files ,watch animated images at the same time.In a multhitreaded program each thread run at the same time and has a different execution path.
    The benefits of multithreading is that we can simultaneously access to multiple applications and minimized the system resource usage.

    Q2) what are the methods for inter-thread communication and what is the class in which these methods are defined?

    Ans>The java.lang.Thread class is used to access threads in multithreaded application.
    A few methods using the thread class are:

    1> getPriority():-Returns the priority of a thread.

    2> isAlive():- determines whether a thread is running.

    3> sleep():-Makes the methodto pause for a periodof time.

    4> getName():-Returns the name of the thread.

    5> start():-Starts a thread by calling the run() methods.

    start(),run() are the Runnable interface to our class.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register