0

Mythread t1 = New Mythread (obj); this code what tells us explain?

5th Jan 2018, 6:18 PM
Prabu Kannan
Prabu Kannan - avatar
2 Respuestas
0
If I'm horribly mistaken then someone can correct me. But I'm pretty sure that creates an Object called "Mythread" with a variable (or reference?) called "t1".
5th Jan 2018, 6:39 PM
Ares Xena
Ares Xena - avatar
0
Ares is correct. Instantiating an object of any type can be done with Type variableName = new Type(); if a no argument constructor is present. If a constructor has more arguments (one in your example) then you insert them accordingly. It looks like you might be trying to create a new thread? If Mythread is a class that extends Thread (a built in Java class) then you can make a new concurrent thread by calling start on t1 (t1.start()). In this case obj would be something that implements the interface 'Runnable'
5th Jan 2018, 10:35 PM
Dan Walker
Dan Walker - avatar