Joining a Timer started thread

Given a piece of code that uses a Timer to start a TimerTask, can the main thread get at the timer-started Thread so it can join() on it?

thrice wrote:
kajbj wrote:
@Op.
Why did you create a new Thread? Um, I'm not sure if you mean "thread" as in a new thread of Java code, or "thread" as in new topic on this forum!I meant thread as in topic.
>
I created new threads in my Java code because I need to get about 50 separate pieces of work done as concurrently as the hardware will allow, while still letting the main thread get work done.
I created a separate topic in this forum because this is a specific question to which I'd like a specific answer!
@All others. Please continue the discussion in the new thread [http://forums.sun.com/thread.jspa?threadID=5344116]
Um, no, please answer this simple question in this thread! I don't know if join()ing to a Timer-started Thread object is the way to solve my overall problem. I suspect it isn't, and your suggestion to use a CountDownLatch reinforces that suspicion.A Timer is single threaded. It will not start 50 threads even if you have 50 timer tasks.
>
For my Java education, I'd like to know if I can join() to a Timer-started thread, and if so, how do I do it?See above.

Similar Messages

  • HOW DO I START THREADS ALL AT ONCE? please help!

    HI! I was just wondering if anybody knew how to start threads all at once. There is the treadgroup stuff but the only method I see there is threadgroup.resume I would like something analogous to threadgroup.start
    any ideas?
    thanks,
    - cunduro

    I don't think you can start all threads at the same time. If what you need is to have all threads ready before they begin doing their job, in the run method you can call a method that waits on some object and when all threads are created (and running and waiting on the object) do a notifyAll(). In that moment all threads will resume working.

  • Timer vs Thread in SessionBean

    Hi,
    I'm having a web service MyWebService which is having a stateless session bean which will invoke a task T1 and soon after starts poll the database after every five seconds to fetch the report of task T1. To wait for that 5 seconds i have two ways.
    1) I'll get the current thread of the bean and call the sleep method. i.e.
    Thread.getCurrentThread.sleep(5000);2) I'll use Timer class i.e
    import java.util.Timer;
    public class TimerTest {
    TimerTest(){}
    public static void main(String args[]){
    Object sync = new Object();
    ResponseTimer responseTimer = new ResponseTimer(sync, timeOut, polDuration);
    responseTimer.cancel();
    static long polDuration = 5000;
    class ResponseTimer extends Timer{
    ResponseTimer(){...}
    public String getResopnse(){
    synchronized(sync){
    while(...){
    try{
    sync.wait(polDuration);
    //POLL DATABASE
    }catch(InterruptedException intrruptedException){...}
    return "Success";
    }Can anyone tell me which is the best way to go for and with how it'll be handled by container?

    If i'll not use Timer or Thread, then what is the way to wait for 5 seconds. My requirement is
    SessionBean is having synchronous call. Once it initiates the task T1, it has to immediately start fetching report of T1 from the database. If report is not present, wait for 5 seconds, again check for the report from database.
    How do i implement the waiting logic inside my bean?

  • Meetings created after some time start shoing up "re-created a meeting that was missing from your calendar" with no body information e.g. Lync meeting

    My manager is having a problem.  "randomly" reoccurring meetings in outlook will after some time start showing as this:
    "Exchange 2013 re-created a meeting that was missing from your calendar"
    With all the "meat" of the body is missing.
    We are running Exchange 2013 SP1 and Outlook 2013.  They look the same in OWA.  Meetings can be from different senders, different times etc.
    Any thoughts?

    Microsoft have confirmed this is an issue with Exchange Online via the O365 Dashboard:
    Current Status: Engineers have developed a fix and are currently testing to ensure successful remediation.
    Customer Impact: Affected customers are experiencing issues with incomplete meeting information for a limited number of invites set to occur between the dates of August 7th, 2014 and September 12th, 2014. For the affected calendar invites, customers may see
    meeting content replaced with a canned message stating, “Exchange 2013 has re-created a meeting that was missing on your calendar.” This issue is only affecting the body of the calendar invite for attendees, and not the meeting organizer.
    Also, this does not affect the title, location, date and time, or the attendee list.
    Workaround: As a workaround, customers can re-send affected calendar invites. Additionally, if the calendar invite contains Lync meeting information and the information does not appear in the message body, attendees may be able to use the ‘Join Lync Meeting’
    button that appears in Outlook, Outlook Web App (OWA), and the mobile client to join the scheduled meeting.
    Incident Start Time: Thursday, August 7, 2014, at 12:00 AM UTC
    Preliminary Root Cause: A recent update to the service caused the Calendar Repair Assistant feature to misidentify some meetings on the attendee’s calendar as missing. By design, the feature recreated the meeting invite, including the title, location,
    date and time, but replaced the body of the calendar invite with the canned message.
    Next Update: Monday, August 18, 2014, at 4:00 PM UTC

  • MaterialMaster_CreateIDOC Cannot start thread

    I am using the Material_Master AOI template with data services I wanted to loop through the IDOC for each plant starting with our main plant then as we loop material would be pushed (extended) to the other plants. When I looped the second time I go the error below. It appears because the connection is already opened for the IDOC another cannot thread be created. Can I close the connection when each plant is pushed and then re-open for the next plant?
    7036       7160       SYS-050703         9/20/2011 2:47:24 PM    |Session Job_P2CMM01_Res_Material_Master|Work flow WF_P2CMM01_Res_MaterialMaster_GenerateIDOC|Data flow DF_P2CMM01_Res_MaterialMaster_CreateIDOC
    7036       7160       SYS-050703         9/20/2011 2:47:24 PM    Cannot start thread.

    Tasks are meant to be run in the context of a JavaFX application, like in the example below:
    import javafx.application.Application;
    import javafx.concurrent.Task;
    import javafx.scene.Scene;
    import javafx.scene.layout.StackPane;
    import javafx.scene.paint.Color;
    import javafx.stage.Stage;
    import java.io.IOException;
    public class TaskApp extends Application {
      public static void main(String[] args) { launch(args); }
      @Override public void start(final Stage stage) throws IOException {
        //create task object
        Task<Integer> task = new Task<Integer>(){
          @Override
          protected Integer call() throws Exception{
            System.out.println("Background task started...");
            int iterations;
            for(iterations = 0; iterations < 10000; iterations++){
              if(isCancelled()){
                break;
              System.out.println("Iteration " + iterations);
              Thread.sleep(3000);
            return iterations;
        //start the background task
        Thread th = new Thread(task);
        th.setDaemon(true);
        System.out.println("Starting background task...");
        th.start();
        stage.setScene(new Scene(new StackPane(), 200, 100, Color.BLANCHEDALMOND));
        stage.show();
    }Also your code was setting the task thread as a daemon thread. The Java Virtual Machine exits when the only threads running are all daemon threads. So once your main routine finished (which would be really quickly), the program would just exit without doing anything much. Note that, in your example, even if you made the Task thread a non-daemon thread, it still doesn't work (likely because the Task class has some reliance on the JavaFX system being initialized). For your simple background process you could skip Task and just use a Runnable or a Callable (which doesn't require JavaFX and hence would work in a non-daemon thread invoked from main), but I guess it's just an experiment.

  • TS3274 its almost 10 months,i purchased ipad2 32 3g wifi.itinially i got problem with applications shut off frequently now since last 4 months my ipad starts with a message (connect iTunes)like first time start and going to restore mode and it occurs freq

    its almost 10 months,i purchased ipad2 32 3G wifi.itinially i got problem with applications and safari shut off frequently now since last 4 months my ipad starts with a message (connect iTunes)like first time start and going to restore mode and it occurs frequently.plz advise.

    If you have followed the standard Apple troubleshooting processes (see user guide )
    probably a trip to the local Apple Store Genius bar is called for before warranty runs out
    Assuming the iPad has been released in your Country if not you may have to take it to a
    neighbouring Country where it is available
    This page will tell you ,via the drop down menu Countries that can support iPad
    http://support.apple.com/kb/index?page=servicefaq&geo=United_Kingdom&product=ipa d

  • Why is time-critical thread not interrupting sleepless high priority thread?

    Hello,
    I have two threads running in the same execution system on a real-time PXI platform. The time-critical thread sleeps using "AI Single Scan.VI", and acquires my data at a rate of 8000 Hz.
    I have a slower high priority process that calls a DLL function to calculate some filter coefficients. This function call takes longer than 1/8000 s to complete, and runs in a loop, executing as often as it can (with new data from FIFOs).
    I expected the time-critical thread to interrupt the the high priority thread without problem.
    I am finding that unless I insert a LabVIEW delay (for example a wait for x ms VI) in the loop, the real-time system stops responding. With a small delay (ie 1 ms), t
    he acquisition completes, and a FIFO shuts down the loop of the slow process.
    Why do I need a labVIEW delay in the high-priority loop, when the DLL function call itself is quite slow? Even without a DLL call, I would expect the time-critical VI to interrupt, finish its data acquisition, and shut-down the high-priority thread using its FIFO.
    Any suggestions?
    Thanks in advance,
    Frenk

    Here are a couple things to try/check:
    1) Check the call library node in your high priority VI. If it's orange (runs in UI thread), your high priority VI is actually switching to the UI thread every time your dll runs. That alone is not a problem. But if your TC VI tries to update any control terminals, the TC thread will switch over to the UI thread to access UI resources, possibly while the dll within your high priority VI has a lock on those resources. Why does the dll have a lock on UI resources? Because it was running in the UI thread and got interrupted by the TC thread before it finished doing its business. Not likely, but possible.
    2) There's another possible reason you're seeing this behavior. If the TC VI and the high VI call a mutual subVI, the subVI will be elevated to ALWAYS run in the highest priority thread irrespective of the actual caller (in your case, it's the the TC thread). Even when the *high priority VI* calls the mutual subVI, that subVI runs in the time-critical thread, which means there's a thread switch from high to TC, then back to high after the subVI finishes. And because high and TC VIs are in the same exec system, that mutual subVI will always run in the 1 and only TC thread alotted to that exec system.
    So, while your TC VI is running, you're in the TC thread. While, your high VI is running, you're in a high non-TC thread, and when your high VI calls the mutual subVI, you're again in the TC thread until the subVI finishes.
    So how could this arrangement cause your TC VI to become starved by the high VI? If your TC VI wakes up while the high VI is in the middle of running the mutual subVI, the TC thread responsible for running the TC VI is actually busy (in the middle of running the subVI in your high VI!!!), so the TC thread cannot run your TC VI until it finishes running that mutual subVI.
    The fix: make your TC VI run in a different exec system. It will be given its own TC thread that no one else can mess with. When TC VI wakes up, it's guaranteed a TC thread.
    I think there's a good reason behind why a mutual subVI ALWAYs runs at the highest priority of all its callers, irrespective of the actual caller's priority...but I can't think of the reason at the moment.

  • Start Thread method behaviour

    I'm using Oracle 10
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining optionsI created two Java classes and a wrapper procedure.
    1. The first class timeOutSAPEntry has a delay caused by sleep method of 10 sec. then updates a row in table sap_entry.
    2. The second class createMonitorSAPEntry creates an instance of timeOutSAPEntry, call start() method and ends.
    3. And the wrapper procedure just calls createMonitorSAPEntry.
    My problem: when I call the wrapper procedure, it hangs for 10 sec (consequence of sleep method). But, I expected that the thread could be created, started and then the control returns to procedure and finishes immediatelly. You can see in the execution below the sysdate before and after the procedure call.
    Is there any solution? I would like the same behaviour of others JVM, where the main thread continues the execution and not hangs out waiting for the started thread.
    create or replace
           and compile java source named "timeOutSAPEntry"
    as
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    public class timeOutSAPEntry
        extends Thread{
        public void run(){
            try{
                 this.sleep(10000);
                 Connection conn =
                        DriverManager.getConnection("jdbc:default:connection:");
                 PreparedStatement  st = conn.prepareStatement("update cmforna.sap_entry set status = 'Failed' where Status = 'Sent'");
                 st.executeUpdate();
                 st.close();
                 conn.commit();
                 conn.close();      
            }catch(Exception e){
                e.printStackTrace();
    create or replace
           and compile java source named "createMonitorSAPEntry"
    as
    public class createMonitorSAPEntry{
       public static void create(){
            timeOutSAPEntry to = new timeOutSAPEntry();
            to.start();
    create or replace procedure create_monitor_post
    as
    language java name 'createMonitorSAPEntry.create()';
    SQL> insert into sap_entry
      2  (id, posted_on, status)
      3  values
      4  (6, sysdate, 'Sent');
    1 row created.
    SQL>
    SQL> commit;
    Commit complete.
    SQL>
    SQL> select to_char(sysdate, 'hh24:mi:ss') Before_Time from dual;
    BEFORE_T
    16:27:04
    SQL>
    SQL> exec create_monitor_post;
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select to_char(sysdate, 'hh24:mi:ss') After_Time from dual;
    AFTER_TI
    16:27:14
    SQL> Many tks,
    Miguel

    Add a KeyAdapter like this:
    addKeyListener(new KeyAdapter() {
      public void keyPressed(KeyEvent ke) {
        int key = ke.getKeyCode();
        if (key == KeyEvent.VK_LEFT) x1--;
        if (key == KeyEvent.VK_RIGHT) x1++;
    });*Note that I added this just after the bouncing = true; ... which is on about line 33.
    **Note that you will need to click in the Applet before the keys will function.
    ***Note that you will also likely want to slow down the balls.
    ~Bill

  • I'm downloading a rented movie, and it's not playing it at all. I go to click it, and the timer starts but it's only a black screen. Help?

    It's downloading, and when I go to play it, the timer starts, but not the movie, and the movie plays and its black screen. I have the latest update. Help!

    What password did you set up in the Setup Assistant when you created your initial user account? This is the password it wants - your admin password. If you did not create one then see below:
    Forgot Your Account Password
    For Lion, Mountain Lion, or Mavericks
        Boot to the Recovery HD:
    Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
         When the menubar appears select Terminal from the Utilities menu.
         Enter resetpassword at the prompt and press RETURN. Follow
         instructions in the dialog window that will appear.
         Or see:
           Reset a Mac OS X 10.7 Lion Password
           OS X Mountain Lion- Reset a login password,
           OS X Mavericks- Solve password problems,
           OS X Lion- Apple ID can be used to reset your user account password.
    For Snow Leopard and earlier with installer DVD
         Mac OS X 10.6- If you forget your administrator password,
         OS X- Changing or resetting an account password (Snow Leopard and earlier).
    For Snow Leopard and earlier without installer DVD
        How to reset your Mac OS X password without an installer disc | MacYourself

  • Data being dropped after joining Fiscal Time with Fact Table

    Hi,
    In my RPD, i have jolined the Fiscal Calendar with my fact tables : Fiscal Day is joined to Create Time column in the fact table.
    Fiscal Day Data is : 6/6/2006 12:00:00
    Creare Time Data is : 6/6/2006 11:45:49
    6/6/2006 11:56:50
    When i pull the fiscal day column with the other columns fromthe fact table in the report, i only see a subset of my data. I beleive this is due to the timestamp and it is causing to drop records.
    Is there anyway, i can join this and not drop records due to the timestamp.
    ANy suggestions will be appreciated.
    Thanks

    I assume that fiscal day table is at the day level. I would suggest that you store the date in an integer format (for example 20060606 'YYYYMMDD') similarly you may store the creation_date_key in fact table which is also in the same format, then do a direct join. This will be provide good performance for your reporting since you are joining integers and not date or char formats.
    If you want time of creation date also, you might want to store it in a seperate column in say HHMMSS format, this when joined with time dimension will allow you hierarchical reporting for time too.

  • Error starting thread: Not enough storage is available to process...

    Hi all,
    We are seeing server going down frequently with below exception:
    [ERROR][thread ] Failed to start new thread
    [2010-04-08 14:36:54,046][ERROR][com.astrazeneca.portal.rss.ContentTransformer] - Error processing item:null
    ; SystemID: http://beaa.astrazeneca.net:10002/NewsBroker/resources/newsToRss.xsl; Line#: 21; Column#: 128
    javax.xml.transform.TransformerException: java.lang.Error: Error starting thread: Not enough storage is available to process this command.
         at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:403)
         at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:426)
         at org.apache.xalan.extensions.ExtensionsTable.extFunction(ExtensionsTable.java:220)
         at org.apache.xalan.transformer.TransformerImpl.extFunction(TransformerImpl.java:437)
         at org.apache.xpath.functions.FuncExtFunction.execute(FuncExtFunction.java:199)
         at org.apache.xpath.XPath.execute(XPath.java:268)
         at org.apache.xalan.templates.ElemVariable.getValue(ElemVariable.java:279)
         at org.apache.xalan.templates.ElemVariable.execute(ElemVariable.java:247)
    I have a weblogic support SR open and they suggested to add -XXtlaSize and -XXlargeObjectLimit to our JVM parameter. With these parameters, we are getting below error in Windows frequently:
    Reporting queued error: faulting application java.exe, version 1.5.0.11, faulting module jvm.dll, version 27.3.1.1, fault address 0x0014b442.
    I have seen few threads on Sun forum, but answer was not posted there. Details of our environment are as below:-
    JVM : JROCKIT 1.5.0.11
    OS : Windows 2003
    Application Server : Weblogic 10
    Any inputs or pointers will be highly appreciated as this is a bit urgent for me...
    Thanks & Regards,
    Sanjeev

    Hi Henrik,
    I am running Weblogic with below parameters now:
    -Xnohup -Xms:1536m -Xmx:1536m -XXtlaSize:min=32k,preferred=768k -XXlargeObjectLimit:32K
    Weblogic crashed again with below dump:
    ===== BEGIN DUMP =============================================================
    JRockit dump produced after 0 days, 07:17:18 on Fri May 07 15:26:16 2010
    Additional information is available in:
    E:\PortalLIVDomaina\jrockit.5772.dump
    E:\PortalLIVDomaina\jrockit.5772.mdmp
    If you see this dump, please open a support case with BEA and
    supply as much information as you can on your system setup and
    the program you were running. You can also search for solutions
    to your problem at http://forums.bea.com in
    the forum jrockit.developer.interest.general.
    Error Message: Illegal memory access. [54]
    Exception Rec: EXCEPTION_ACCESS_VIOLATION (c0000005) at 0x005148AF - memory at 0x00000000 could not be written.
    Minidump : Wrote mdmp. Size is 1406MB
    SafeDllMode : -1
    Version : BEA JRockit(R) R27.3.1-1_CR344434-89345-1.5.0_11-20070925-1628-windows-ia32
    GC Strategy : Mode: throughput. Currently using strategy: genparpar
    GC Status : OC currently running, in phase: sweeping. This is OC#3000.
    : YC is not running. Last finished YC was YC#9937.
    OC History : Strategy genparpar was used for OC#1.
    : Strategy singleparpar was used for OC#2.
    : Strategy genparpar was used for OC#3 to OC#3000.
    YC History : Ran 11 YCs before OC#2996.
    : Ran 18 YCs before OC#2997.
    : Ran 11 YCs before OC#2998.
    : Ran 8 YCs before OC#2999.
    : Ran 1 YCs before OC#3000.
    Heap : 0x00900000 - 0x60900000
    Compaction : 0x06900000 - 0x0C900000
    Could you please provide some input on this?
    Thanks,
    Sanjeev

  • My iphone 4s shuts itself off all the time. starts normal and then shut it off and start all over again, what is wrong?

    my iphone 4s shuts itself off all the time. starts normal and then shut it off and start all over again, what is wrong?

    Your iPHone is designed by intention to shut off when there is a reason for the softwarer to believe that danger is immenent to the hardware. This can occurr if the software is running applications that have been corrupted due to all types of different scenarios. My best advice to you would be to restore your device back to default manufactures settings and do NOT restore the current backup of the IOS program currently running.
    If this corrects the problem with your device intermittently restarting you will then know you have had applications there were corrupted on your device. Once you are convinced there are no issues with the hardware of your device you then are free to begin downloading software apps that were earlier on the device.
    Good luck.

  • OBIApps - 11.1.1.7 Fact table joining to time Dim by default

    Hi,
    I am trying to pull a column only from the Fact table F1 and not pulling any Dimension columns into the report criteria. But when I run the results and look for the physical SQL, BI is joining the Time dimension table to the Fact table. Does any one know where this is being enforced in the BIAPPS RPD?
    Thanks!!

    Did you used only fact table for report and it joins with dimensional table at answers ?

  • When does the test time start? After installing the program? Or only after opening the program? background: I accidently installed the Photoshop test version, but O am still busy with testing Premiere Pro.

    when does the test time start? After installing the program? Or only after opening the program? background: I accidently installed the Photoshop test version, but O am still busy with testing Premiere Pro.

    Freialeben7 the evaluation period begins when you first launch the Adobe application you are wishing to evaluate.

  • To display splash screen for certian period of time using threads

    i want to write a program to display splash screen for certian period of time using threads. could some one help me

    If you just want a splash screen: [http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/splashscreen/|http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/splashscreen/]
    If you want to learn threads: [http://java.sun.com/docs/books/tutorial/essential/concurrency/|http://java.sun.com/docs/books/tutorial/essential/concurrency/]

Maybe you are looking for