How to make a function in separate thread

i need to make a function that is running in a separate thread
Thank's in advance

Thank's
but in my program i have a main class which is a server it runs forever.
from the main class when i call a function it runs in a separate thread and returns the result to the callee and the main function continue it's work
class server
//this function when called must be in separate thread
public int function(int x)
//there could be wait here or sleep
return x*2;
public static void main(String[] args)
// Run RMI server
i hope u understand me!!!
Thank's

Similar Messages

  • How to make a function return number(10,0) data type (ORACLE 10g)?

    With 10g, how to make a function return number(10,0) data type?
    here is the function, it returns a number type :
    create or replace FUNCTION Get_portfolio_Id3 (p_HistObjTable In Varchar2,p_LHISTOBJID IN NUMBER) RETURN view_cpu_STD_Asset.LPORTFOLIOITEMID%Type IS
    v_Id view_cpu_STD_Asset.LPORTFOLIOITEMID%Type;
    BEGIN
    If p_HistObjTable ='amPortfolio'
    then v_Id:=p_LHISTOBJID ;
    elsIf p_HistObjTable = 'amComputer' then
    select litemid into v_Id from smcdba.amComputer c where c.LCOMPUTERID=p_LHISTOBJID ;
    else v_Id:=-99;
    End If;
    RETURN v_Id;
    END Get_portfolio_Id3;
    Thanks.
    Message was edited by:
    user631701

    create or replace FUNCTION Get_portfolio_Id3 (p_HistObjTable In Varchar2,p_LHISTOBJID IN NUMBER) RETURN view_cpu_STD_Asset.LPORTFOLIOITEMID%Type IS
    v_Id view_cpu_STD_Asset.LPORTFOLIOITEMID%Type;
    BEGIN
    If p_HistObjTable ='amPortfolio'
    then v_Id:=p_LHISTOBJID ;
    elsIf p_HistObjTable = 'amComputer' then
    select litemid into v_Id from smcdba.amComputer c where c.LCOMPUTERID=p_LHISTOBJID ;
    else v_Id:=-99;
    End If;
    RETURN round(v_Id);
    END Get_portfolio_Id3;

  • PL/SQL: How to make a function accessible to all users?

    How can I make a function accessible to all users?
    I have written a stored function called GET_NET_BALANCE.
    I can run it but my users cannot.
    I have tried the following, but my users still cannot
    run the function:
    GRANT EXECUTE ON GET_NET_BALANCE TO PUBLIC;
    Thanks, Eileen

    Hi,
    You can try creating a public synonym on the function so that it is accessible to all.
    To get greater response.. please post your question at
    PL/SQL
    Regards,
    Anupama

  • How to make a function take a specific group of constants

    I know i asked this before, maybe a year ago, but I totally forgot how to do it, and I haven't been programming much lately. But I was wondering if somebody can tell me how to make a certain function take specific constants. For example there are java functions, of which I can not remember that will only take certain values. So the function might look like:
    public getInfo(String INFONAME){}Where INFONAME has to be like one of two names or something, and they are constants that are defined somewhere else. If anybody knows what I mean by this, and knows how to create functions like that please let me know. Thank you.

    here's an overkill,
    import java.util.*;
    abstract class DoWhatever {
        public static Hashtable ht = null;
        public static Object DoWhat( String s, Object obj ) {
         if( null == ht ) {
             ht = new Hashtable();
             ht.put( ThisDoWhatever.NAME, new ThisDoWhatever() );
             ht.put( ThatDoWhatever.NAME, new ThatDoWhatever() );        
         return ( (DoWhatever) ht.get( s ) ).doWhatever( obj );
        public abstract Object doWhatever( Object obj );
    class ThisDoWhatever extends DoWhatever {
        public final static String NAME = "this";
        public Object doWhatever( Object obj ) {
         System.out.println( NAME );
         return null;
    class ThatDoWhatever extends DoWhatever {
        public final static String NAME = "that";
        public Object doWhatever( Object obj ) {
         System.out.println( NAME );
         return null;
    public class DoThisOrThat {
        public static void main( String[] args ) {
         DoWhatever.DoWhat( args[ 0 ], null );
    }

  • Mailing list form, how to make it functional?

    I'm trying to add the typical "Join our Mailing List" form into a website where users can submit their email addresses.  I've built the form and now I need to make it functional.  I don't know a lick of php or databasing, and after investigating it on the web and the forum there seems to be a bunch of different answers and I'm not sure which direction to go in.  Is there an easy way to do this with a premade script somewhere?  Would I have to get it from the company that's hosting the site?  How do I implement it?
    Thanks in advance!!!!

    Awesome, thanks so much for the help CanonBoy.  So I can use this for both my mailing list form and my contact message form?  I opened Dreamweaver and on the contact page I set the form to this:
    <div id="ContactForm">
      <form id="form1" name="form1" method="post" action="contact.php">
        <table width="300">
          <tr>
            <td colspan="2"><span class="MainText">All information will be kept private</span></td>
          </tr>
          <tr>
            <td width="61"><span class="MainText">Name:</span></td>
            <td width="227"><span class="MainText">
              <input name="Name" type="text" id="Name" size="25" />
            </span></td>
          </tr>
          <tr>
            <td><span class="MainText">Email:</span></td>
            <td><span class="MainText">
              <input name="Email" type="text" id="Email" size="25" />
            </span></td>
          </tr>
          <tr>
            <td><span class="MainText">Phone:</span></td>
            <td><span class="MainText">
              <input name="Phone" type="text" id="Phone" size="25" />
            </span></td>
          </tr>
          <tr>
            <td> </td>
            <td> </td>
          </tr>
          <tr>
            <td><span class="MainText">Message:</span></td>
            <td><span class="MainText">
              <textarea name="Message" id="Message" cols="23" rows="5"></textarea>
            </span></td>
          </tr>
          <tr>
            <td> </td>
            <td> </td>
          </tr>
          <tr>
            <td> </td>
            <td><input name="Clear" type="reset" class="MainText" id="Clear" value="Clear" />
            <input name="Submit" type="submit" class="MainText" id="Submit" value="Submit" /></td>
          </tr>
        </table>
      </form>
    </div>
    Do I have to change the form ID and the name in line 2?  And also I'm not sure what you meant about the hidden field, what exactly do I copy and paste and where do I put it?  And is there a generic form on the tectite site I can add the client's email address to, change it to contact.php and upload it?  Thanks big time!!!

  • How to make this function module as RFC to get data from different system?

    Hi
    I am trying to use following function module . This function module is used to copy data from one cube to another cube within same system however I need a this should happen across two different system. How can I use this function module to make it remote call to different system and do the same function what it is doing ?
    Name of function module -
    RSDRT_INFOCUBE_DATA_COPY
    Any help would be really helpful
    AG

    HI,
      let us say you want to copy the data of a cube in system A to a cube in system B .
      1) create a RFC function module in system B (in this function module  call the function module RSDRI_CUBE_WRITE_PACKAGE to update the data), this RFC function module should have same parametersa as RSDRI_CUBE_WRITE_PACKAGE .
    2) write a program in system A .. read the data from the infocube using the function module RSDRI_INFOPROV_READ and call the RFC function module in system B that you have created..
    for the details of the parameters to pass to these two function modules use the RSDRT_INFOCUBE_DATA_COPY and get the required code
    Thanks
    mahesh

  • How to make a function out of a query

    Hi,
    I have the following query:
    select
    to_date(sysdate, 'DD.MM.YYYY') as "FULL_DATE",
    to_number(to_char(sysdate, 'D')) as "DAY_OF_WEEK",
    to_number(to_char(sysdate, 'DD')) as "DAY_NUMBER_IN CALENDAR_MONTH",
    to_number(to_char(sysdate, 'DDD')) as "DAY_NUMBER_IN CALENDAR_YEAR"
    from
    dual
    how to I make a funtion where I can input a start and an ending date and it calculates allt the rows fow the days in between?
    Thanks,
    Walter

    drop type mytabletype;
    create or replace type mytype as object (
    full_date date,
    dow number,
    daynum_m number,
    daynum_y number
    create or replace type mytabletype as table of mytype;
    create or replace function myfunc (p_date in date) return mytabletype pipelined as
      cursor cur_mycur is
      select
        to_date(p_date, 'DD.MM.YYYY') as "FULL_DATE",
        to_number(to_char(p_date, 'D')) as "DAY_OF_WEEK",
        to_number(to_char(p_date, 'DD')) as "DAY_NUMBER_IN_CALENDAR_MONTH",
        to_number(to_char(p_date, 'DDD')) as "DAY_NUMBER_IN_CALENDAR_YEAR"
        from dual;
      x mytype := mytype(null,null,null,null);
    begin
      for i in cur_mycur
      loop
        x := mytype(i.full_date,i.day_of_week,i.day_number_in_calendar_month,i.day_number_in_calendar_year);
        pipe row(x);
      end loop;
    end;
    sho err
    select * from table(myfunc(sysdate));
    select * from table(myfunc(to_date('15/09/2006','dd/mm/yyyy')));is this what you're after.
    If so I suggest you take it away, and get an understanding for it. It's a very useful technique to know.
    I know it doesn't do all the days between 2 dates, but that should be something you can do with a little thought.
    Regards
    Message was edited by:
    blushadow

  • How to make mp3s play in separate window from original Safari window

    I am trying to drive a musical production from a local html file of the script (text of the play), with links to local mp3 files. Now, Safari brings up a QuickTime window to replace the script window. This makes it hard to follow the script to see when it's time to pause the mp3, etc. How can I configure Safari to play the mp3s in a separate window?

    <update on my situation> I learned that Crtl-click brings up a menu to open in new window or new tab. That's much better, but odd that the same Safari Preference settings don't work (single click uses QT plugin).
    I tried Firefox 3.5.5, and am getting the same results. I adjusted the treatment of mp3 and x-mp3 to use iTunes, but even after exiting Firefox and restarting, it only opens QT either using QT plugin (click) or separate tab/window (ctrl-click).
    Firefox 3.5.4 on Windows works fine: I left-click on the mp3 link, and it brings up a separate WMP window.

  • How to make this function random chose bits and flip it

    Hi ni and member
    I try to make this vi that do this function 
    I need it to use in academic research
    I have  stream of bits  have length=100bitsmove in serial
    and I want a selector that select between ratio  0.1 0.2 or 0.05 that represent error ratio
    its ratio of bit that much flip (0 to 1) and (1 to 0)
    for exqmple
    for 0.1 ratio 10 bit of stream must randomly chosen and flipped
    for 0.5 ratio  50 bit of stream must randomly chosen and flipped
    any help please
    best regards
    hi ?Q>

    GerdW wrote:
    Hi mangood,
    - use a ring or enum for your selector
    - depending on the selector value create a boolean array containing randomly set bits
    - XOR your boolean array with your stream bit array
    Done...
    thank you with kudos
    i did not understand the stament """use a ring or enum for your selector"""
    can you make a pic for the vi  
    best regards
    hi ?Q>

  • How to make a function call.

    Hello ,
    I tried to call the function in Form Calc but there are some error. can any one say the right syntax to be used.Please find example what i tried
    if(x eq 1) then
    values()
    endif
    func values()
    xfa.host.messageBox("test")
    endfunc
    Kindly any one let me know where i went wrong
    Best Regards,
    Rakesh

    Hi Rakesh,
    If you look at page 966 of the XFA specification (http://partners.adobe.com/public/developer/xml/index_arch.html#xfa_28), then you will see how to decalre and call a function in FormCalc:
    func MyFunction(param1) do param1*param1 endfunc // Declares a function
    MyFunction(3) //Invokes the function, which returns 9
    It looks like your previous FormCalc function was missing the "do" call.
    Bear in mind that if you start putting functions in script objects, you will have to revert to Javascript.
    Good luck,
    Niall

  • How to make this function in enviroment?

    Hi I think I need some help here.
    I want to set a enviroment to switch the audio instruments like the VSL performence tool:
    when I press the first key on the midi keyboard, the first instruments plays , and then the second press , the second instruments play then the third press, the first instruments play .....i mean 2 instrument play in turns .
    so anyone here can give me some suggestion how to build this enviroment?
    Thanks at first.

    this is easy to setup with logic.
    if you go to logicprohelp.com and look up environments and templates, download my basic orchestral template and you will see how i do it.
    basically you set up a GM instrument cabled to a transformer and then to an audio instrument. the transformer then converts information you specify to control aspects of the audio instrumnet/s. in my case i use it to convert program changes to operate keyswitches or articulation switches in my custom made instruments.
    to quickly achieve what you want to do use a cable switcher or selector in faders -> special to switch between different audio instruments.
    - first create a GM instrument, name it and bring it up in arrange.
    - then cable it to a cable switcher in the environment.
    - cable the first cable to 1 AI then the next to the next and so on.
    - select the cable switcher and define the paramter that will activate the switch in the paramters box on the LH side of the screen in environment. you may need to make sure that the midi channels match.
    now, when you do your keyswitch or program change or set a controller the cable switcher will switch the midi information to the correct AI.
    have a look at the percussion page in the environment of my full orchestral template to see how it works if you get stuck.

  • How to make one function of an equation a constant?

    Many of my spreadsheets are designed to be expanded over time: for instance, I track my expenses and add new rows and columns each month.
    When I drag-copy formulas to the new rows or columns, Pages obligingly changes the calculations in cells to reflect the new cell coordinates.  (A1+B1 becomes B1+C1)
    However, in some equations I would like certain functions to remain constant.  How do I write such a formula?  (A1+B1 would become A1+C1 ... A1+Z1)
    Thank you.

    iWork Formulas and Functions User Guide isn't delivered to help helpers to help you.
    Yvan KOENIG (VALLAURIS, France) jeudi 6 octobre 2011 11:29:49
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • How to make my tables not to threadding to a new page until its fill the page i'm working on?

    After the 1st row, the 2nd row supposed to be on the bottom of the 1st page... but it's happen otherwise... it's keep threadding to a new page.. It's also happens to the 3rd row... Anybody here know how to fix this...? I already using 5 hours just to solve this prob but nothing happens... x_X

    hmmn Ok, im still on CS5.5 here at home...
    here is a link tho.
    https://dl.dropboxusercontent.com/u/7716845/tableQuick.indd
    i did this in a few minutes and created a few cell styles. The way forward for you is learn about table formatting and cell styles as well as utilizing headers etc.
    let me know if it helps.
    /G

  • How to make room for other new threads?

    When I run my program for a relatively long period of time, a memory problem occurs!
    There are a number of threads in my program running simultaneously (for example 16) created from a single class, and in every one of them, there are two different threads, which are responsible for some different periodic jobs. So I sleep them for a random time periodically, and they do that job in a repeating manner. On the other hand, each one of theses main (16) threads, invoke some methods of the other ones, with a random delay. In order to implement this delayed invocations, without blocking the hole thread itself, I use a Timer and its method, schedule(object, delay). In another class which I pass an instant of it as the first argument of schedule(object, delay), I invoke the method of another main thread (one of those 16 threads).
    But the problem is after running my program for a while, this error shows up, and the program doesn't act normally after that:
    "Exception in thread "Timer-11324(or some other number like this)" java.lang.OutOfMemoryError: unable to create new native thread"
    What should I do? Does these Timers and their background threads dispose after their times passed? Or, should I dispose it manually? If it is so. how can I do that?
    Thanks

    There is a block of code like this in some methods of a class, which each of my 16 threads initiated from this class.
    class Messaging
         int Broadcast_Delay;
         public void Broadcast()
              Timer Broadcast_Delay_Timer = new Timer();
              for(int i=0 ; i < 16 ; i++)
                   //A random number between 0 and 100, generated by uniform distribution, as the timer delay
                   Broadcast_Delay = StdRandom.uniform(0, 100);
                   //Scheduling to run the run() method of an instance of class Broadcasting, with that random delay
                   Broadcast_Delay_Timer.schedule(new Broadcasting(i, trigger_pid, trigger_inum), Broadcast_Delay);
    class Broadcasting
         run()
    }So a block of code like this runs a lot in my program, infinitely.
    You are right, I put the declaration of these timers inside the methods in the main class, but they must be outside them!
    You all were right!!!
    But if I put the deceleration outside the methods, and directly in the main class, and if we invoke a method having this timer.schedule() continuously, is there a problem for last scheduled jobs?
    Thanks

  • How 2 make a function that gets a value from DB without reloading?

    Hi every1,
    I'm facing this problem where I have to get a value (which always change) from database through a button function which is in Java scriplet.
    Now the scriplets (codes within <% and %>) contain calls to the database which get the value, but this is only done when the page loads. So everytime I neeed to get the latest value, I need to reload the code. Is there a way around this?
    Thanks!
    Regards,
    Venus

    Add a meta refresh header to let the page refresh itself at certain intervals.
    <meta http-equiv="refresh" content="10">This will refresh the current page every 10 seconds.
    By the way, Java code belongs in Java classes, not in JSP files. Avoid scriptlets as much as possible. In this case use a Servlet and a DAO.

Maybe you are looking for