473,386 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

multithreading without importing Thread class

65
how can a multithreaded code can be compiled succesfully without importing Thread class?

the example below is taken from marcus green mock exam 1:

Expand|Select|Wrap|Line Numbers
  1. public class Rpcraven{
  2.     public static void main(String argv[]){
  3.     Pmcraven pm1 = new Pmcraven("One");
  4.     pm1.run();
  5.     Pmcraven pm2 = new Pmcraven("Two");
  6.     pm2.run();
  7.  
  8.     }
  9. }
  10.  
  11. class Pmcraven extends Thread{
  12. private String sTname="";
  13. Pmcraven(String s){
  14.     sTname = s;
  15.  
  16. }
  17. public void run(){
  18.     for(int i =0; i < 2 ; i++){
  19.         try{
  20.          sleep(1000);
  21.         }catch(InterruptedException e){}
  22.  
  23.         yield();
  24.         System.out.println(sTname);
  25.         }
  26.  
  27.     }
  28. }
Oct 22 '07 #1
3 1418
JosAH
11,448 Expert 8TB
The Thread class is in the java.lang package which gets imported implicitly, just
like String, Object etc.

kind regards,

Jos
Oct 22 '07 #2
stmfc
65
thanks for your reply.
one more question, what is the full list of classes imported implicitly?
all classses in java.lang package?
Oct 22 '07 #3
JosAH
11,448 Expert 8TB
thanks for your reply.
one more question, what is the full list of classes imported implicitly?
all classses in java.lang package?
I don't know all classes in the java.lang package by head but yes, they're all
implicitly imported; it is as if the first line in your program looks like this:

Expand|Select|Wrap|Line Numbers
  1. import java.lang.*;
  2.  
kind regards,

Jos
Oct 22 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: dixp | last post by:
I'm new to writing multithreaded apps and I have a design question. I have a winforms app and a class which has a method that does processing which is time intensive. I want the user to be able...
47
by: mihai | last post by:
What does the standard say about those two? Is any assurance that the use of STL is thread safe? Have a nice day, Mihai.
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
16
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
6
by: VM | last post by:
I'm trying to add multithreading to my win application but I'm having trouble with the code since the method to be threaded has parameters. How can I add multithreading to a method with parameters?...
9
by: tommy | last post by:
hi, i have found a example for multithreading and asp.net http://www.fawcette.com/vsm/2002_11/magazine/features/chester/ i want to speed up my website ... if my website is starting, they...
4
by: Manuel | last post by:
I have a long function that needs to be done 1000 times. I'm multithreading it, but I don't want to load them up all at once, instead load them 10 at a time. So far the only way I can get it to...
6
by: Michael | last post by:
I have an application that monitoring some directories. When new file arrives my application importing that file into database (very long process) I want to rewrite this application to multithread...
2
by: lewisms | last post by:
Hello all, I am quite new to c++/. Net so please don't shoot me down for being a newbie. Any way I am trying to make a simple multithreading program that is just to learn the ideas behind it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.