Type mismatch: cannot convert from void to Thread

Ojas Landge

I am trying to make a program in java the accepts any connection but I getting this error:

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
Type mismatch: cannot convert from void to Thread

at ojas.gome.Server.<init>(Server.java:37)
at ojas.gome.Server.main(Server.java:12)

This piece of code gives me this error:

clientaccepter = new Thread(new Runnable() {
            public void run() {
                while(true) {
                    try {
                        server.accept();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }, "clientaccepter").run();

Please tell me if I left out anything needed.

D.B.

You're setting a variable equal to the result of the run method which does not return a value - it's void.

clientaccepter = new Thread....run();

You should declare the thread and then start it on a separate line if you need to retain a reference to it. Also, you should use start to begin a new Thread not run. Please see Defining and Starting a Thread. Lastly, variables should be camel case starting with lowercase - please see Java Naming Conventions.

clientAccepter = new Thread(...);
clientAccepter.start();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Type mismatch: cannot convert from void to Integer

From Dev

Type mismatch: cannot convert from void to int

From Dev

Color.RGBToHSV Type mismatch: cannot convert from void to float[]

From Dev

Type mismatch: cannot convert from boolean to int

From Dev

Type mismatch: cannot convert from ListFragment to Fragment

From Dev

Type mismatch: cannot convert from long to int

From Dev

type mismatch: cannot convert from double to Double

From Dev

Type mismatch cannot convert from String to String[]

From Dev

Type mismatch: cannot convert from Scanner to boolean

From Dev

Type mismatch: cannot convert from int to TextView

From Dev

Type mismatch : cannot convert from double[][] to double[]

From Dev

Type mismatch: cannot convert from boolean to double

From Dev

Type mismatch cannot convert from String to String[]

From Dev

Type mismatch: cannot convert from double to double[]

From Dev

Type Type mismatch: cannot convert from RegisterFragment to Fragment

From Dev

Type mismatch: cannot convert from element type Object to Cookie

From Dev

type mismatch cannot convert from element type object to string

From Dev

Java - Type mismatch: cannot convert from element type Object to String

From Dev

type mismatch cannot convert from element type object to string

From Dev

Type mismatch: cannot convert from element type Object to Cookie

From Dev

Java - Type mismatch: cannot convert from element type Object to String

From Dev

Type mismatch: cannot convert from element type Object to List

From Dev

cannot convert from type void* (class name)(void*) to type void* (*)(void*) in a pthread

From Dev

Type mismatch: cannot convert from Class<capture#1-of ?> to Class<?>[]

From Dev

Type mismatch: cannot convert from Class<Parameterized> to Class<? extends Runner>

From Dev

Type mismatch: cannot convert from java.lang.String to String

From Dev

Type mismatch: cannot convert from Object to Class object

From Dev

Java generics. Type mismatch: cannot convert from object to

From Dev

GWT UIBinder Type mismatch: cannot convert from ImageResource to Image

Related Related

  1. 1

    Type mismatch: cannot convert from void to Integer

  2. 2

    Type mismatch: cannot convert from void to int

  3. 3

    Color.RGBToHSV Type mismatch: cannot convert from void to float[]

  4. 4

    Type mismatch: cannot convert from boolean to int

  5. 5

    Type mismatch: cannot convert from ListFragment to Fragment

  6. 6

    Type mismatch: cannot convert from long to int

  7. 7

    type mismatch: cannot convert from double to Double

  8. 8

    Type mismatch cannot convert from String to String[]

  9. 9

    Type mismatch: cannot convert from Scanner to boolean

  10. 10

    Type mismatch: cannot convert from int to TextView

  11. 11

    Type mismatch : cannot convert from double[][] to double[]

  12. 12

    Type mismatch: cannot convert from boolean to double

  13. 13

    Type mismatch cannot convert from String to String[]

  14. 14

    Type mismatch: cannot convert from double to double[]

  15. 15

    Type Type mismatch: cannot convert from RegisterFragment to Fragment

  16. 16

    Type mismatch: cannot convert from element type Object to Cookie

  17. 17

    type mismatch cannot convert from element type object to string

  18. 18

    Java - Type mismatch: cannot convert from element type Object to String

  19. 19

    type mismatch cannot convert from element type object to string

  20. 20

    Type mismatch: cannot convert from element type Object to Cookie

  21. 21

    Java - Type mismatch: cannot convert from element type Object to String

  22. 22

    Type mismatch: cannot convert from element type Object to List

  23. 23

    cannot convert from type void* (class name)(void*) to type void* (*)(void*) in a pthread

  24. 24

    Type mismatch: cannot convert from Class<capture#1-of ?> to Class<?>[]

  25. 25

    Type mismatch: cannot convert from Class<Parameterized> to Class<? extends Runner>

  26. 26

    Type mismatch: cannot convert from java.lang.String to String

  27. 27

    Type mismatch: cannot convert from Object to Class object

  28. 28

    Java generics. Type mismatch: cannot convert from object to

  29. 29

    GWT UIBinder Type mismatch: cannot convert from ImageResource to Image

HotTag

Archive