Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

parallel processing thread

nothing display when i run my code idk why  🤮 some one help me ?

Quote:Error Message :
run:
BUILD SUCCESSFUL (total time: 1 second)

[Image: VGF2vVw.png]
[Image: a4G0z11.png]
[Image: OFpQpgJ.png]
Writeln('Give me a Target >');
[Image: giphy.gif]
I think you have to implement the run method like so:
Code
// Java code for thread creation by extending
// the Thread class
class MultithreadingDemo extends Thread
{
    public void run()
    {
        try
        {
            // Displaying the thread that is running
            System.out.println ("Thread " +
                  Thread.currentThread().getId() +
                  " is running");
  
        }
        catch (Exception e)
        {
            // Throwing an exception
            System.out.println ("Exception is caught");
        }
    }
}
  
// Main Class
public class Multithread
{
    public static void main(String[] args)
    {
        int n = 8; // Number of threads
        for (int i=0; i<8; i++)
        {
            MultithreadingDemo object = new MultithreadingDemo();
            object.start();
        }
    }
}
[Image: 0DvFxnA.gif]
Donate: 3ABKRghau93ziRaDfVwiiwtjky3i1gLrKn
Seems like you've created a class called "mythread", which has a method called runz().
When you go back to your "main" class you create the object "mythread" but you call function start(), instead of runz().
(Apr 3, 2019 10:01 AM)802.1X Wrote:  Seems like you've created a class called "mythread", which has a method called runz().
When you go back to your "main" class you create the object "mythread" but you call function start(), instead of runz().

His class extends Thread so it already has the method start(), which calls run()

@OP you simply need to use the same name of the method you want to override, so run() not runz()


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by simmerApr 9, 2022 02:34 PM 5 246 Apr 9, 2022 02:34 PM
Last Post: simmer
[Python] by thebuzisnotMar 22, 2021 02:55 PM 5 215 Mar 22, 2021 02:55 PM
Last Post: Lindros
[Java] by Nemo2478Oct 28, 2019 01:42 AM 0 176 Oct 28, 2019 01:42 AM
Last Post: Nemo2478