Multithread and join
public class MyTest
public static void main(String[] args) throws IOException
{ System.out.println("starting main thread");
new SimpleThread("Jamaica").start();
new SimpleThread("Fiji").start();
join(); // process main thread when all multithread finised. whats the correct syntax ?
System.out.println("ending main thread");
class SimpleThread extends Thread {
public SimpleThread(String str) {
super(str);
public void run() {
for (int i = 0; i < 10; i++) {
System.out.println(i + " " + getName());
try {
sleep((int)(Math.random() * 1000));
} catch (InterruptedException e) {}
System.out.println("DONE! " + getName());
}of course, this code will not work. but i want to do something like that . can i make it working ?
no, this way it can not work. now, first thread is finishing first . after that, second thread is finished and at last the main thread is finished.
i did not want this.
i wanted first and second thread should do as they do but when both of them are done , they should print
System.out.println("ending main thread");
can not join() do this ?
test code :
import java.io.*;
public class MyTest
public static void main(String[] args) throws Exception
{ System.out.println("starting main thread");
//new SimpleThread("Jamaica").start();
//new SimpleThread("Fiji").start();
SimpleThread t[]=new SimpleThread[3];
for (int i = 0;i<2; i++) {
t=new SimpleThread(i+"");
t[i].start();
t[i].join();
// process main thread when all multithread finised. whats the correct syntax ?
System.out.println("ending main thread");
class SimpleThread extends Thread {
public SimpleThread(String str) {
super(str);
public void run() {
for (int i = 0; i < 10; i++) {
System.out.println(i + " " + getName());
try {
sleep((int)(Math.random() * 1000));
} catch (InterruptedException e) {}
System.out.println("DONE! " + getName());
Similar Messages
-
WWhen I set up family sharing i did it with me as family organizer, but as my spouse is the organizer I had to leave the "family" I created and join his. But while setting it up an error occurred, and the screen went blank. Now I tried to join his family sharing again, and my phone keeps telling me I can't because accounts can only join families twice a year.
I Don't really want to wait 364 days from now, is there a way in which I can reset my accoint so I can join family sharing again?
Apple support doesn't have a solution for me yet!
KInd regardsThis morning I looked at my family sharing account again an IT WORKS NOW! Think Apple has done a reset to my account, though I'm not exactly sure why! So I hope it works for you guys as well!
-
Multiple rows Converge to Single row and join
Hi Folks,
I am facing a tricky challenge to join a table with multiple rows and converge into a single row (based on ID, period) and join with another table to get a single row. Let me explain.
Table 1: DTL_TABLE (id, period, course, names, title, type)
1 2010 mat john null null
1 2010 mat jim null null
1 2010 cam null officer null
1 2010 cam null Prof null
1 2010 phy null null Inclass
1 2010 phy null null Online
Join with
Table 2: ID_TABLE(id, period, Loc, Dept, Code)
1 2010 nj 101 CC.
Output format (id, period, course, names, title, type, Loc, Dept, Code)
result : 1 2010 mat,cam,phy john,jim officer,prof inclass,online nj 101 CC
I have created all the DDLs and DMLs if that help. Kindly let me know if a Join SQL query is possible.
Thank you,
Aj
CREATE TABLE DTL_TABLE
ids VARCHAR2 (10),
period VARCHAR2 (10),
course VARCHAR2 (10),
names VARCHAR2 (10),
title VARCHAR2 (10),
TYPE VARCHAR2 (10)
INSERT INTO DTL_TABLE
VALUES ('1',
'2010',
'mat',
'jim',
NULL,
NULL);
INSERT INTO DTL_TABLE
VALUES ('1',
'2010',
'mat',
'john',
NULL,
NULL);
INSERT INTO DTL_TABLE
VALUES ('1',
'2010',
'mat',
'kale',
NULL,
NULL);
INSERT INTO DTL_TABLE
VALUES ('1',
'2010',
'cam',
NULL,
'officer',
NULL);
INSERT INTO DTL_TABLE
VALUES ('1',
'2010',
'cam',
NULL,
'prof',
NULL);
INSERT INTO DTL_TABLE
VALUES ('1',
'2010',
'phy',
NULL,
NULL,
'inclass');
INSERT INTO DTL_TABLE
VALUES ('1',
'2010',
'phy',
NULL,
NULL,
'online');
COMMIT;
CREATE TABLE id_table
ids VARCHAR2 (10),
period VARCHAR2 (10),
loc VARCHAR2 (10),
dept VARCHAR2 (10),
code VARCHAR2 (10)
INSERT INTO id_table
VALUES ('1',
'2010',
'nj',
'101',
'cc');
COMMIT;Aj09 wrote:
Hi Folks,
I am facing a tricky challenge to join a table with multiple rows and converge into a single row (based on ID, period) and join with another table to get a single row. Let me explain.
Table 1: DTL_TABLE (id, period, course, names, title, type)
1 2010 mat john null null
1 2010 mat jim null null
1 2010 cam null officer null
1 2010 cam null Prof null
1 2010 phy null null Inclass
1 2010 phy null null Online
Join with
Table 2: ID_TABLE(id, period, Loc, Dept, Code)
1 2010 nj 101 CC.
Output format (id, period, course, names, title, type, Loc, Dept, Code)
result : 1 2010 mat,cam,phy john,jim officer,prof inclass,online nj 101 CC
I have created all the DDLs and DMLs if that help. Kindly let me know if a Join SQL query is possible.
SELECT TBL.id,
DTLperiod,
course,
names,
title,
TYPE,
Loc,
Dept,
Code
FROM ID_TABLE TBL,
DTL_TABLE DTL
WHERE TBL.ID = DTL.ID
AND TBL.PERIOD = DTL.PERIOD; it not good to use RESERVED WORDS like "ID" or "TYPE" as column names -
I used the wrong password to join my new belkin wifi. Now that I have the correct password, I can not get the to the join screen with the space to type in the password. I continue to get the unable to join message. I have put the touch to sleep and I have turned on and off the wifi and join options on the Network screen page. Does anyone know how to get pass this block of the wrong password to a new page that will allow me to type in the correct password. I see there is a option that asks if I want to reset the network settings.. is that what I should do? and what does it erase when I do that? Thanks for any input anyone has.
Yes. Reset network settings. Head to Settings -> General -> Reset and tap Reset Network Settings.
B-rock -
Mid month Relieving and joining
Hi All,
Relieving and joining during mid of the month are not getting pro- rated.
System is able to pro-rate the salary for any unpaid absence but not for relieving and joining cases.
What is that I am missing? Please tell
Regards
AsthaHi,
Relieving in the middle of the month:
Please check the payroll status infotype - 0003 of the relieved employee and mark the relieving date at field "Run Payroll upto" field.
Joining in the middle of the month:
Please check the date specification infotype - 0041 of the employee joined in the middle of the month (i.e hiring date) and mark it in that infotype.
After completing above process. Run the payroll.
Lets wait, what other experts says for this.
Regards,
Shadeesh.G -
Hi,
what is the differnce between view and join tableHi,
There are 4 types of views in SAP.
Database View - To club more than one table
Projection View - To hide fields in one table
Maintenance View - To maintain database records in table
Help View - To provide help for a fields (Same functionality as Search help. This is outdated)
View are improves performance in the following aspects
1. If you want to use more than two table in 'JOIN' condition better to use Views . It will improves performance of a program
2. If you want to use mutiple FOR ALL ENTRIES clause, better to club all SELECT statement in a view.
Note:
1.Views does not contain data in it. It fetches data from the database only depending on the condition ...
2.Views are part of data dictionary. They are a window to view the data in database
3.views can be used to give security to data. users can be allowed to view only basic data only
For More Info,go thru this Threads,
join
Views vs Inner Join
Regards,
Padmam. -
Using Case and Joins in update statement
Hi all,
I need to update one column in my table...but need to use case and joins...I wrote the query and it is not working
I am getting an error msg saying...the SQL command not ended properly...
I am not that good at SQL...Please help...
update t1 a
set a.name2=
(case
when b.msg2 in ('bingo') then '1'
when b.msg2 in ('andrew') then '2'
when b.msg2 in ('sam') then '3'
else '4'
end )
from t1 a left outer join t2 b
on a.name1 = b.msg1 ;
Waiting for help on this...!
Thanks in Advance... :)Another approach is to update an inline view defining the join:
update
( select a.name2, b.msg2
from t1 a
join t2 b on b.msg1 = a.name1 ) q
set q.name2 =
case
when q.msg2 = 'bingo' then '1'
when q.msg2 = 'andrew' then '2'
when q.msg2 = 'sam' then '3'
else '4'
end;which could also be rewritten as
update
( select a.name2
, case q.msg2
when 'bingo' then '1'
when 'andrew' then '2'
when 'sam' then '3'
else '4'
end as new_name
from t1 a
join t2 b on b.msg1 = a.name1 ) q
set name2 = new_name;The restriction is that the lookup (in this case, t2.msg1) has to be declared unique, via either a primary or unique key or unique index.
(You don't strictly need to give the view an alias, but I used 'q' in case you tried 'a' or 'b' and wondered why they weren't recognised outside the view.) -
Select Distinct and join in ODI
Hi,
I have following task to perform: I am loading metadata into Planning dimension from Oracle database. I have two tables
1. "Sales"
Columns: Name, Number, Value
Sample Data:
Product 1, 10, 200
Product 2, 30, 100,
Product 1, 15, 500
2. P&R
Columns:
Name, Alias
Product 1, SampleSoda1
Product 2, SampleSoda2,
Resource 1, CanForSoda,
Resource 2, CO2
What I need to do is: I have to select name and alias from second table of all products that were sold.
So I need to select distinct Name from Table 1, naxt join it with Table 2 (so I have Name and Alias) and load it to planning.
I am a little confused how to do it.
Any help would be great!
Best regards,
GregHi Greg,
What you can do is either :
- Create a yellow interface with your table Sales as source. Map the name column directly in the target. In the flow tab, click on your target and select "Distinct rows".
- Create a second interface, with your first interface as source. Select the "Use Temporary Interface as Derived Table (Sub-Select)" checkbox.
- Add your second datastore and join it. Or you can use a lookup table.
OR
- Create an interface with Sales and P&R as source (or set P&R as a lookup table).
- Go on the flow tab and select "Distinct rows".
If you've a lot a data in the first table, I would go for the first solution.
Hope it helps.
Regards,
JeromeFr
Edited by: JeromeFr on Feb 14, 2013 9:52 AM
To be more clear in the first step of solution 1 -
My Macbook Pro constantly drops my network and joins Linksys. It connects to the Internet but is painfully slow. Choosing my network again works for a while than goes back to Linksys. Any sugestions?
Try going to system preferences/network/advanced, airport tab, in the prefered networks pane highlight and drag your net work to the top of the list. See if it then chooses your network as prefered, hope this helps.
-
Why can't I use the Average and Join commands in an action?
Something I do a hundred times a day is select two endpoints, average them, and join them. I tried to make an action and map it to an Fkey, but Illustrator won't allow the Average or Join commands in an action. When I tried using the Insert Menu Command, it made Illustrator crash. Finally I managed to do it without Illustrator crashing, but there is then no way to hit "OK" in the Average dialog box via the Actions palette. Why is this apparently impossible?
You have to use Actions Palette Flyout menu >> insert menu item to get those menu items reocorded.
To get action to stop crashing you need to Actions Palette Flyout menu >> Playback Options >> 1 sec or greater.
There already are keyboard commands CMD J & OPT CMD J for these. Unfotunately you cannot record for example the next menu choice step such as BOTH. A script likely could be written for this though, and you can try posting in the Illustrator scripting forum. -
Creating a collection from a list and joining the list to a database table
I would like to have opinions on good ways to process rows, based on a provided list of key values, joining the collected list against a source table to retrieve additional information related to the key. In this simple example, the procedure accepts a list of employee numbers. The goal is to print a list of names associated with those numbers. The method is to materialize the list of employee numbers as rows and join those rows to a source table to get the names. I have used BULK COLLECT. I don't know if this is a good approach and I would value suggestions. I would also like to understand why we cannot cast PLSQL tables using a type defined in the procedure's specification (why the type needs to exist as an object before we can cast it, like this:
SELECT * FROM TABLE ( CAST ( SOME_FUNCTION(&some parameter) AS SOME_TYPE ) );
Anyway, here is my demo SQL, which you should be able to execute against the SCOTT schema without any changes. Thanks for your help!
declare
type employee_numbers is table of emp.empno%type index by binary_integer;
type employee_names is table of emp.ename%type index by binary_integer;
type employees_record is record (empno employee_numbers, person_name employee_names);
records employees_record;
employees_cursor sys_refcursor;
employee_number_list varchar2(30) default '7369,7499,7521';
begin
open employees_cursor for
with t as (
select regexp_substr(employee_number_list, '[^,]+', 1, level) as employee_number
from dual
connect by regexp_substr(employee_number_list, '[^,]+', 1, level) is not null
) select emp.empno, emp.ename
from t join emp on (emp.empno = t.employee_number)
order by 2
fetch employees_cursor bulk collect into records.empno, records.person_name;
dbms_output.put_line('number of records: '||records.empno.count());
for i in 1 .. records.empno.count
loop
dbms_output.put_line(chr(39)||records.empno(i)||chr(39)||','||chr(39)||records.person_name(i)||chr(39));
end loop;
end;>
It looks like I have confirmation that BULK COLLECT is a good way to go collect rows for processing
>
Well maybe and maybe not. Bear in mind that those demos were only basic demos for the purpose of illustrating how functionality CAN be used. They do not tell you WHEN to use them.
BULK COLLECT uses expensive PGA memory and unless you know that only a small number of rows will be collected you can have some serious memory issues. Any heavy duty use of BULK COLLECT should generally have a LIMIT clause to limit the number of elements in the collection for each loop iteration.
Always use SQL if possible.
Also, for your use case you might be bette served using a PIPELINED function. Instead of collecting ALL rows into a nested table as in your example a PIPELINED function returns one row at a time but is still used as if it were a table using the same TABLE operator.
Here is simple example code for a PIPELINED function
-- type to match emp record
create or replace type emp_scalar_type as object
(EMPNO NUMBER(4) ,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7, 2),
COMM NUMBER(7, 2),
DEPTNO NUMBER(2)
-- table of emp records
create or replace type emp_table_type as table of emp_scalar_type
-- pipelined function
create or replace function get_emp( p_deptno in number )
return emp_table_type
PIPELINED
as
TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
emp_cv EmpCurTyp;
l_rec emp%rowtype;
begin
open emp_cv for select * from emp where deptno = p_deptno;
loop
fetch emp_cv into l_rec;
exit when (emp_cv%notfound);
pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
end loop;
return;
end;
select * from table(get_emp(20)) -
I have canceled my account same day and joining because the convert PDF to word did not convert correctly how to get credit for cancelled membership
You need to contact Adobe Customer Support :
They will check and assist you. (Live Chat)
Contact Customer Care -
Query to get a listing of all folders and joins in EUL
If anybody has a query that provides a listing of all folders and joins between those folders in a Discoverer EUL, can you please share it.
Any help would be greatly appreciated.Hi
As Rod commented you won't get an accurate listing going through XREFS. You need to look in the statistics table, EUL5_QPP_STATS where you will find a history of all worksheets that have been executed. Unfortunately the item columns in EUL5_QPP_STATS are encoded so you will need some special SQL to uncode them.
First of all you will need to have installed the EUL extensions which can be found in the script called EUL5.SQL (located in the Discoverer\Util folder where Admin is installed) when logged in as the owner of the EUL. Theh try running this script, altering the data switch to a suitable date:
SELECT
QS.QS_DOC_OWNER USER_NAME,
QS.QS_DOC_NAME WORKBOOK,
QS.QS_DOC_DETAILS WORKSHEET,
TRUNC(QS.QS_CREATED_DATE) EXECUTION_DATE,
*(LENGTH(TO_CHAR(EUL5_GET_ITEM_NAME(QS.QS_ID)))+1)/9 ITEMS,*
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),1, 6)) ITEM1,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),10, 6)) ITEM2,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),19, 6)) ITEM3,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),28, 6)) ITEM4,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),37, 6)) ITEM5,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),46, 6)) ITEM6,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),55, 6)) ITEM7,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),64, 6)) ITEM8,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),73, 6)) ITEM9,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),82, 6)) ITEM10,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),91, 6)) ITEM11,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),100,6)) ITEM12,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),109,6)) ITEM13,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),118,6)) ITEM14,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),127,6)) ITEM15,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),136,6)) ITEM16,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),145,6)) ITEM17,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),154,6)) ITEM18,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),163,6)) ITEM19,
EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),172,6)) ITEM20
FROM
EUL5_QPP_STATS QS
WHERE
*(LENGTH(TO_CHAR(EUL5_GET_ITEM_NAME(QS.QS_ID)))+1)/9 < 21*
AND QS.QS_CREATED_DATE > '01-JAN-2009'
Best wishes
Michael -
Select and join one month record
I receive a request from my customer . He want generate a total sales record for a month and those data stored in daily sales table and customer table.
tblcustomer-20140101
tblcustomer-20140102
tblcustomer-20140103
tblcustomer-20141231
tblsales-20140101
tblsales-20140102
tblsales-20140103
tblsales-20141231
is there anyway when user select month name from application(ex: April), it will choose all april record and join it together?Hi kjleong,
Generally to say, it is not a good practice to store the same entity data individually for each day, there are many shortages, such as the problem you posted in this thread. You can put all of them into one table and tag them with a DATE column. Anyway
in this case, to achieve your requirement, you may refer the below stored procedure(SP).
CREATE PROC ProcGetSales
@Year VARCHAR(20),
@Month VARCHAR(20)
AS
DECLARE @Date DATE;
DECLARE @Days INT;
DECLARE @SqlStr NVARCHAR(MAX);
SET @Date = @Year+'-'+@Month+'-01';
SET @Days = DATEDIFF(DAY,@Date,DATEADD(MM,1,@Date)); --get the days of the specific month
create a temp table
CREATE TABLE #Temp
col1 int --you should put the columns after join in your real envrioment here
table join statement, put the join result into a temp table
I dont know the columns so I use * here and the join condition is just based on assumption
you should modify the statement basing on your real environment
SET @SqlStr= 'INSERT INTO #Temp SELECT * FROM [tblcustomer-WhichDay] tc JOIN [tblsales-WhichDay] ts ON tc.customerID = ts.customerID';
DECLARE @Counter INT = 1;
WHILE @Counter <= @Days --loop the tables named after the specific month
BEGIN
DECLARE @Sql NVARCHAR(MAX) = REPLACE(@SqlStr,'WhichDay',CONVERT(VARCHAR(8),CAST(@Year+'-'+@Month+'-'+LTRIM(STR(@Counter)) AS DATE),112));
EXEC sp_executesql @Sql;
SET @Counter = @Counter+1;
END
SELECT * FROM #TEMP
The SP is not ready to use, you have to make some modification basing on your real environment before it works.
If you have any question, feel free to let me know.
Best regards,
Eric Zhang
If you have any feedback on our support, please click
here. -
Hi friends,
I am looking for some wisdom here!
Just wondering if I can use a 5508 WLC in Hong Kong and join 3602 APs in Vietnam to it?
Any regulatory contsraints / guidelines that would prohibit from doing so?
- Regards,
Tarun.You have two differnt regulations... here is a link:
http://www.cisco.com/en/US/prod/collateral/wireless/ps5679/ps5861/product_data_sheet0900aecd80537b6a_ps10981_Products_Data_Sheet.html
You need to make sure you are not breaking any rules and it is best to have an AP that is specific to that country. Also if you add multiple country codes on a WLC, the AP's will only be able to use the most common channels and TX power setting allowed on both. Here is a link explaining that.
http://nostringsattachedshow.com/2012/02/02/multiple-country-codes-with-the-cisco-wlc/
Thanks,
Scott
Help out other by using the rating system and marking answered questions as "Answered"
Maybe you are looking for
-
I have setup a test system. It has a domain with 2 child domains. DomainA.xyz.com has users and workstations. DomainB.xyz.com is a resource domain and has servers. wyx.com is for IT administration. Users in domainA can logon to the domainB computer
-
Forms 10.1.2.0.2
Does anyone know the release date of Oracle Forms 10.1.2.0.2? I saw messages saying that it would be released in June. Will WebUtil be available with that Forms version? Also, is there any suggestion of how to upgrade Oracle JInitiator on clients' PC
-
[SOLVED] Awesome Windows Manager terminal not opening
Hello, I recently reinstalled Arch on my UEFI laptop. It went pretty smoothly, apart from the fact that whenever I start up arch it says that it failed to activate my swap partition. But that's not the problem I'm posting about. I installed Xorg, and
-
any apps or ways I can open a bak file?
-
Adobe Application Manager won't launch
Running Mac OSX Lion on Macbook Pro with Adobe Creative Cloud. When I try to launch Acrobat Pro, Application Manager tries to launch, but no options come up. Happens every time I try to launch Acrobat, so Acrobat won't work. Suggestions? I noticed t