• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Threads

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Q1. What do Daemon threads mean and what is the difference between a daemon thread and other thread?
Q2. What does static synchronized method do? What it is the difference between static and non static synchronized method?
Thank u
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A daemon thread persists as a service; other threads return when their run() code completes, so that the program can terminate once all threads terminate. A daemon thread will run until it is interrupted.
If a method is both static and synchronized, then accessing the method requires a class lock instead of an object lock. The consequence of this usage is that only one person can use that method at a time, and the class locks access for the duration.
-----------------
Michael Ernest, co-author of:

    The Complete Java 2 Certification Study Guide


    [This message has been edited by Michael Ernest (edited December 08, 2000).]
 
umang bhartia
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

According to u a daemon thread will run until it is interrupted, then how v can interrupt it. Please throw some more light on this topic.
For the second Question, even if a method is synchronized and not static then also only one thread will b able to access it at a time, or it is that if a method is only synchronized then other thread can access other synchronized method of that class. Please explain again if possible
thank u
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michel,
You said "when method is declared Static and Synchornized... only one thread (person) can access at any given point of time"
Does this mean all other methods in the class are also locked. Then it means class at that point ( when the method is used ) is behaving as Static also .. even if it is not declared !!
Secondly, when method in a class is non-Static and synchronized.. you can create instances of that class and then different threads can access that method ( unlike previous one ) .. is this so ?
tks,
Ashish
 
Think of how dumb the average person is. Mathematically, half of them are EVEN DUMBER. Smart tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic