473,796 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multithreading without importing Thread class

65 New Member
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 1438
JosAH
11,448 Recognized Expert MVP
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 New Member
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 Recognized Expert MVP
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
2054
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 to kick off the process and continue to work in the appliaction while getting progress updates and the ability to cancel. The method that seems easiest to me is this: The class exposes certain events for progress. Start, ProgressUpdate, and...
47
3759
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
4273
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 threads of a multithreaded program using embedded SQL. Since the threads do not need to share transaction scopes, the sqleAttachToCtx family of APIs do not seem to be necessary. <quote> In the default implementation of threaded applications against...
16
8511
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
2921
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? MSDN says ThreadStart cannot take parameters, so how can I do it? public System.Threading.Thread Thread_LoadAZM; public void LoadFile(string sFileName) { Thread_LoadAZM=System.Threading.Thread(new...
9
2466
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 should build a database-connection and send a few sqls
4
1725
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 work is by creating a dummy form with a timer. On the timer function I test if the number of threads are less than 10 then run the remaining ones. This is working fine, but I would like to know how to do it without the form. This is the code...
6
1675
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 application so if multiple files arrive at the same time the directory monitor should start new thread for each file . I don't need any feedback from importing routine (all information about flow stored into log file). I am looking for some...
2
4410
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 (before I incorporate them in another program). I just can’t seem to get a non-static call to work in my thread that has access to the Form1 variables and controls I need. I can call a non-static function using another class but then I can seem to get in...
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10230
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10012
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7548
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.